Hello all i have following code. This code runs every time someone clicks
a button of the parent componet.
The issue is when the app starts it runs the ngOnInit() and that runs
this.CheckDisplayBrands("A").
The Console.log(brandtype) will show an A and everything is sorted. If the
function is run through the parent the console log will show the update ie
B but the sorting is not happening.
ngOnInit(): void {
this.brands = this._brandService.getBrands();
this.CheckDisplayBrands("A");
}
CheckDisplayBrands(brandtype){
console.log(brandtype);
this.displayBrands = this.brands.filter(brand => brand.parent ===
brandtype);
if(brandtype == "ALL"){
this.displayBrands = this.brands;
}
console.error(this.displayBrands);
}
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/angular/bd522bb0-e7ab-4241-a2c2-72a496885810%40googlegroups.com.