-
Notifications
You must be signed in to change notification settings - Fork 26.5k
Description
I'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 ]