hybrid mode : loading ng1 components dynamically using ViewContainerRef.createComponent()

1 view
Skip to first unread message

prasad....@gmail.com

unread,
Jul 11, 2016, 6:00:05 AM7/11/16
to Angular2
Hi,

i have a use case where i need to load the ng1 components dynamically inside ng2 parent component.

Here is the plunker: https://plnkr.co/edit/HADJILztGEELg5lavfvP?p=preview

However, it throws following exception when loading ng1 components:

ViewWrappedException {_wrapperMessage: "Error in ./DynamicComponent class DynamicComponent - inline template:0:27", _originalException: TypeError: Cannot read property 'scope' of null
at new UpgradeNg1ComponentAdapter (https://npmcd…, _originalStack: "TypeError: Cannot read property 'scope' of null? …ular/co...@2.0.0-rc.2/bundles/core.umd.js:8276:49)", _context: DebugContext, _wrapperStack: "Error: Error in ./DynamicComponent class DynamicCo…DNGqj1u/src/dynViewComponent.ts!transpiled:84:45)"}_context: DebugContext_originalException: TypeError: Cannot read property 'scope' of null

Michiel Kikkert

unread,
Jul 11, 2016, 6:49:56 AM7/11/16
to Angular2
It seems your upgrade adapter is called multiple times. Haven't had time to go through your code in detail, but maybe this give you some clues:

prasad....@gmail.com

unread,
Jul 12, 2016, 4:32:13 AM7/12/16
to Angular2
figured out the problem.. The issue is hybrid mode requires all the upgrades be done before UpgradeAdapter.bootstrap() is called. Hope they fix it in the Uprgade adapter to allow NG1 upgrades after app is boostrapped. Logged issue with angular2 [#9959](https://github.com/angular/angular/issues/9959)

Michiel Kikkert

unread,
Jul 12, 2016, 5:12:09 AM7/12/16
to Angular2
Great!
Reply all
Reply to author
Forward
0 new messages