Hybrid mode doesn't allow NG1 upgrades after app is bootstrapped.
See original GitHub issueI’m submitting a … (check one with “x”)
[ X] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
Loading a component dynamically using ViewContainerRef.createComponent()
fails in case of ng1 child component. The issue here is NG2 component being loaded dynamically contains an NG1 child component. And Upgrade Adapter fails to bind the scope of upgraded NG1 component throwing below exception.
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./DynamicComponent class DynamicComponent - inline template:0:0
ORIGINAL EXCEPTION: TypeError: Cannot read property 'scope' of null
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'scope' of null
at new UpgradeNg1ComponentAdapter (https://npmcdn.com/@angular/upgrade@2.0.0-rc.4/bundles/upgrade.umd.js:440:57)
at new UpgradeNg1ComponentAdapterBuilder.type._angular_core.Directive.Class.constructor (https://npmcdn.com/@angular/upgrade@2.0.0-rc.4/bundles/upgrade.umd.js:293:36)
at DebugAppView._View_DynamicComponent0.createInternal rc.4/bundles/core.umd.js:12207:48)
Expected/desired behavior It should be possible to load a ng1 component dynamically in hybrid mode. Upgrade Adapter should allow NG1 upgrades even after app is bootstrapped.
Reproduction of the problem Here is the plunker : https://plnkr.co/edit/HADJILztGEELg5lavfvP?p=preview
What is the expected behavior? It should be possible to load a ng1 component dynamically in hybrid mode.
What is the motivation / use case for changing the behavior? Due to this issue, it’s not possible to (re) use the ng1 components inside ng2 app.
Please tell us about your environment:
- Angular version: 2.0.0-rc.4
- Browser: [Chrome 51 ] Version 51.0.2704.106 m
- Language: [all | TypeScript 1.8 | ES5 ]
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
The same with services. After the application bootstraped you cant use services.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.