我已经使用angular2(升级选项)将angular1 app升级为bootstrap,但在使用systemJS config导入angular后:
map: {... 'angular': 'npm:angular/angular.js' ... }
浏览器发送错误:
systemjs.import error: Error: (SystemJS) angular.module is not a function TypeError: angular.module is not a function at execute (http://msoqa05.devlab.ad:8088/home/bl/app.module.js:88:21) at ZoneDelegate.invoke (https://unpkg.com/zone.js@0.7.4?main=browser:242:26) at Zone.run (https://unpkg.com/zone.js@0.7.4?main=browser:113:43) at https://unpkg.com/zone.js@0.7.4?main=browser:520:57 at ZoneDelegate.invokeTask (https://unpkg.com/zone.js@0.7.4?main=browser:275:35) at Zone.runTask (https://unpkg.com/zone.js@0.7.4?main=browser:151:47) at drainMicroTaskQueue (https://unpkg.com/zone.js@0.7.4?main=browser:418:35) at XMLHttpRequest.ZoneTask.invoke (https://unpkg.com/zone.js@0.7.4?main=browser:349:25) Error loading http://msoqa05.devlab.ad:8088/home/bl/app.module.js
也许我不理解它,但为了导入角度我需要在systemjs.config中映射它?为什么?
我正在尝试降级app.module.ts中的angular2 componentsnet:
import * as angular from 'angular'; import { downgradeComponent } from '@angular/upgrade/static'; angular.module('myApp') .directive( 'helloWorld',downgradeComponent({component: HelloWorldComponent}) as angular.IDirectiveFactory );
ts编译没问题,但浏览器不能正常使用它我得到了这个错误. angular.module是angularJS的基础?
解决方法
这样做解决了这个问题:
无需使用systemjs导入角度.
无需使用systemjs导入角度.
import * as _angular_ from 'angular'; declare global { const angular: typeof _angular_; }