I am successfully emitting Event explicitly by running another change detection process outside Zone JS.
Though the change detection is running, Error: ApplicationRef.tick is called recursively error.
Looking at its API .4.3/packages/core/src/application_ref.ts#L347-L417
tick() method is getting stuck in Try-Catch block and not going to Finally hence throwing the recursive error. Line 563-576
This is the method in which I am calling in the Application.tick()
public listenTeamOverview(assetName: string) {
console.log('parent : ' + assetName);
console.log('assetClass= ' + this.assetClass);
this.assetClass = assetName;
this.application.tick();
// setTimeout(function(app) {
// app.tick();
// }, 2000, this.application);
}
Would just like to understand conceptually as to how to e out of this recursion process of tick() method?
Thanks in Advance
I am successfully emitting Event explicitly by running another change detection process outside Zone JS.
Though the change detection is running, Error: ApplicationRef.tick is called recursively error.
Looking at its API https://github./angular/angular/blob/4.4.3/packages/core/src/application_ref.ts#L347-L417
tick() method is getting stuck in Try-Catch block and not going to Finally hence throwing the recursive error. Line 563-576
This is the method in which I am calling in the Application.tick()
public listenTeamOverview(assetName: string) {
console.log('parent : ' + assetName);
console.log('assetClass= ' + this.assetClass);
this.assetClass = assetName;
this.application.tick();
// setTimeout(function(app) {
// app.tick();
// }, 2000, this.application);
}
Would just like to understand conceptually as to how to e out of this recursion process of tick() method?
Thanks in Advance
Share Improve this question edited Dec 4, 2017 at 8:48 Dmitry 7,27614 gold badges41 silver badges41 bronze badges asked Sep 27, 2017 at 9:22 Aditya ShuklaAditya Shukla 3461 gold badge4 silver badges20 bronze badges 9-
3
You're running
tick
during theApplication.tick
execution. Why do you need it? You can just use setTimeout for that. After setTimeout tick will be called automatically – yurzui Commented Sep 27, 2017 at 9:29 - I tried to do the setTimeout, not working. adding the mented out timeout code in the question. there is something which I am doing wrong, can you help me out ? – Aditya Shukla Commented Sep 27, 2017 at 9:32
- You do not need to call app.tick inside setTimeout – yurzui Commented Sep 27, 2017 at 9:34
- Can you tell me the correct way please? – Aditya Shukla Commented Sep 27, 2017 at 9:36
-
Just call
setTimeout
if your want to call the whole change detection cycle orcdRef.detectChanges
if you want to run change detection for current ponent and its children – yurzui Commented Sep 27, 2017 at 9:37
1 Answer
Reset to default 8Another working solution for me: use ChangeDetectorRef instead of ApplicationRef
constructor(private ref:ChangeDetectorRef) { }
somethingChanged() {
this.ref.detectChanges();
}