为什么system.js返回一个空对象而不是angularjs?如何解决?
System.config({
map: {
angular: 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js'
}
});
System.import('angular').then(function(data){
console.log('###', data);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.js"></script>
答案 0 :(得分:1)
因为AngularJS是在全局级别加载的,not as a module.
执行导入后,angular
在全局范围内可用。
System.config({
map: {
angular: 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js'
}
});
System.import('angular').then(function(){
console.log(angular);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.js"></script>
答案 1 :(得分:1)
System.config({
map: {
angular: 'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js'
},
meta: {
'https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.3/angular.js': {
'format': 'global'
}
}
});
System.import('angular').then(function(data){
console.log('###', data);
});
&#13;
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.18.4/system.js"></script>
&#13;