import * as angular from 'angular' inside app.module.ts file

import * as angular from 'angular' inside app.module.ts file

我已经使用 angular2(升级选项)将 angular1 应用程序升级到 bootstrap,但是在使用 systemJS 配置导入 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

也许我没看懂,但是为了导入angular我需要把它映射到systemjs.config里面?为什么?

我正在尝试降级 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
    );

ts 编译没问题,但浏览器不支持,我得到这个错误。 angular.module是angularJS的基础?

这样做解决了问题: 无需使用 systemjs 导入 angular。

import * as _angular_ from 'angular';

declare global {
  const angular: typeof _angular_;
}