4

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/[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

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?

1
  • I checked the log: angular.module is undefined, so I did something wront. angular is defined as a Module Commented Feb 12, 2017 at 22:07

1 Answer 1

9

Doing so solved the problem: no need to import angular with systemjs.

import * as _angular_ from 'angular';

declare global {
  const angular: typeof _angular_;
}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.