Hybrid app fails to bootstrap AngularJS if loaded from import #16484
Comments
This happens because By default, it looks on Promise.resolve().
then(() => System.import('angular')).
then(() => System.import('app')).
catch(err => console.error(err)); Alternatively, (on latest versions) you can explicitly set the AngularJS lib before you bootstrap (as seen in that example): // main.ts
...
import {setAngularLib} from '@angular/upgrade/static';
import angular from 'angular';
setAngularLib(angular);
platformBrowserDynamic().bootstrapModule(DemoAppModule); Closing since everything works as expected and what you want is already possible. |
Thank you @gkalpak . setAngularLib is just what I was looking for. I hadn't spotted this in the changelog |
@greg73, it is in the "Features" section for the 4.1.0-rc.0 release. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
I'm submitting a ... (check one with "x")
Current behavior
Attempting to bootstrap a hybrid app using UpgradeModule, if AngularJS is loaded using
import * as angular from 'angular'
then the console reports the error 'AngularJS v1.x is not loaded!' if AngularJS is loaded from a script tag, the application boostraps correctly without error.Expected behavior
It should be possible to load AngularJS using import
Minimal reproduction of the problem with instructions
not working - https://plnkr.co/edit/KJijAJY8lQYRnnwuGOSK?p=preview
working (with script tag) - https://plnkr.co/edit/VQWj0OOmY5SF2i2Y9RmI?p=preview
What is the motivation / use case for changing the behavior?
To allow AngularJS to be bundled easily and use its type definitions
Please tell us about your environment:
Chrome 58 on Windows 10
Angular version: 4.1
Browser: Chrome 58 on Windows 10
Language: Typescript 2.1
The text was updated successfully, but these errors were encountered: