Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 从'导入*作为角度;角度';内部app.module.ts文件_Angular_Typescript_Systemjs - Fatal编程技术网

Angular 从'导入*作为角度;角度';内部app.module.ts文件

Angular 从'导入*作为角度;角度';内部app.module.ts文件,angular,typescript,systemjs,Angular,Typescript,Systemjs,我已使用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 funct

我已使用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中映射它?为什么?

我正在尝试降级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编译很好,但是浏览器不适合,我得到了这个错误。angularJS的基础是angular.module?

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

import * as _angular_ from 'angular';

declare global {
  const angular: typeof _angular_;
}

我检查了日志:angular.module未定义,所以我做了一些修改。角度被定义为一个模块