passing of argument from parent does not work

11 views
Skip to first unread message

Darius Kirschner

unread,
Mar 15, 2020, 3:23:51 PM3/15/20
to Angular and AngularJS discussion
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);
 
}

bastien lemaire

unread,
Apr 7, 2020, 5:15:44 AM4/7/20
to Angular and AngularJS discussion
Hi, could you provide a stackblitz demo with the minimum reproduction code, please?
Reply all
Reply to author
Forward
0 new messages