I have upgrade angular1 app to bootstrap with angular2 (upgrade option), but after importing angular with systemJS config:
map: {... 'angular': 'npm:angular/angular.js' ... }
The browser send error:
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
Maybe I did not understand it, but in order to import angular I need to mapped it inside systemjs.config? Why?
I am trying to downgrade angular2 componenet inside app.module.ts:
import * as angular from 'angular';
import { downgradeComponent } from '@angular/upgrade/static';
angular.module('myApp')
.directive(
'helloWorld',
downgradeComponent({component: HelloWorldComponent}) as angular.IDirectiveFactory
);
The ts compile is fine with that, but the browser not ok with it and I get this error. angular.module is the basic of angularJS?
Doing so solved the problem: no need to import angular with systemjs.
import * as _angular_ from 'angular';
declare global {
const angular: typeof _angular_;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.