خرید بک لینک

Vote count: 0

I asked a question recently to see if it's possible to conditionally load modules based on selectors on the page (e.g, by id, data-* attribute). The answer indicated that this could be done in the following way:

const map = {
  '#one': 'one',
  '#two': 'two'
};

for (let selector in map) {
  if (document.querySelector(selector)) {
    System.import(map[selector]);
  }
}

To follow-up with this, I want to know if it's possible to System.import() inside of a .then promise callback of a System.import. For example:

System.import('map').then(function(m) {
  var map = m[0];
  for (let selector in map) {
    if (document.querySelector(selector)) {
      System.import(map[selector]);
    }
  }
});

When I run this, I receive an error tracing back to System.import(myMap[selector]):

Uncaught (in promise) Error: Caot read property '0' of null

Is it possible to System.import inside of a promise from another System.import?

asked 41 secs ago

- - , .

برچسب: نویسنده: استخدام کار تاريخ: يکشنبه 16 اسفند 1394 ساعت: 7:27

صفحه بندی