2017-02-12 16 views
2

我有升級angular1應用與angular2(升級選項)來引導,但角度進口角與systemJS配置後:進口*從「角」內app.module.ts文件

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/[email protected]?main=browser:242:26) 
     at Zone.run (https://unpkg.com/[email protected]?main=browser:113:43) 
     at https://unpkg.com/[email protected]?main=browser:520:57 
     at ZoneDelegate.invokeTask (https://unpkg.com/[email protected]?main=browser:275:35) 
     at Zone.runTask (https://unpkg.com/[email protected]?main=browser:151:47) 
     at drainMicroTaskQueue (https://unpkg.com/[email protected]?main=browser:418:35) 
     at XMLHttpRequest.ZoneTask.invoke (https://unpkg.com/[email protected]?main=browser:349:25) 
    Error loading http://msoqa05.devlab.ad:8088/home/bl/app.module.js 

也許我不明白它,但爲了導入角我需要映射它在systemjs.config?爲什麼?

我想降級裏面app.module.ts angular2組元:

import * as angular from 'angular'; 
import { downgradeComponent } from '@angular/upgrade/static'; 

angular.module('myApp') 
    .directive(
     'helloWorld', 
     downgradeComponent({component: HelloWorldComponent}) as angular.IDirectiveFactory 
    ); 

的TS編譯是細跟的是,但瀏覽器不就OK了,我得到這個錯誤。 angular.module是angularJS的基礎嗎?

+0

我檢查了日誌:angular.module是未定義的,所以我做了一些事情。角度被定義爲一個模塊 – AngularOne

回答

3

這樣做解決了問題: 無需導入與systemjs的角度。

import * as _angular_ from 'angular'; 

declare global { 
    const angular: typeof _angular_; 
}