ApplicationRef bootstrap(...) not working as expected

7 views
Skip to first unread message

Ankur Gupta

unread,
Oct 3, 2019, 9:00:42 AM10/3/19
to Angular and AngularJS discussion
Hi All,

In my application I am trying to bootstrap component at runtime for which I am using 

bootstrap(AComp, '#' + containerId);

But doing so, rendered the component correctly but actions on it was not working. Like two way data binding was not working on it. To fix this I had to do

const ngZone: NgZone = this.injector.get(NgZone);
ngZone
.run(() => {
 
this.appRef.bootstrap(AComp, '#' + containerId);
});

Is this normal? 

I am using the Angular 8.

Ankur Gupta

unread,
Oct 3, 2019, 9:00:42 AM10/3/19
to Angular and AngularJS discussion
Hi All, I am trying to bootstrap a component at runtime for which I am using
applicationRef.bootstrap(AComponent, containerId);

However doing so its rendering my component correctly but nothing in that component works. Like two way binding is not working. To make it work I had to do 
const ngZone: NgZone = this.injector.get(NgZone);
ngZone
.run(() => {

 
this.appRef.bootstrap(AComponent, '#' + containerId);
});

Is this normal?
Reply all
Reply to author
Forward
0 new messages