Reputation: 747
I have a project in angular 8, basically it's kind of a distribution system, each component run independently with its own server and services and then i am using that component as a plugin in my main application where several components are running independently as a plugin. so the issue is, when the component run independently, it works fine but when i used it as a plugin in main application , it is not detecting changes for events/clickable events. Every time i need to add ref.detectChanges() beneath the functions. How to achieve this immediately and change detection's without manually writing ref.detectChanges() after each model change ?. Any help will be highly appreciated. Thanks
hideDropdown(){
this.showDropdwn = !this.showDropdwn;
this.cdRef.detectChanges();
}
getConfig() {
this.frontofficeApiService.getConfig(this.tile.webApiRoot).subscribe(data => {
this.bpsData = data.bps;
this.qtyData = data.quantity;
this.cd.detectChanges();
})
}
Upvotes: 0
Views: 382
Reputation: 94
If the changes are getting reflected only after detectChanges() method of ChangeDetectorRef, then your component is detached from the change detection tree. Have to tried to call reattach method of ChangeDetectorRef in the ngOnInit method of the component?
Upvotes: 1