ngOnChanges not working in Angular4
Asked Answered
R

1

3

I know I am not the first to ask this question ,And I have tried the solutions of so many post in Stackoverflow regarding this but nothing is helped for me .

I have an accordion menu in my parent component when the user clicked on those menus the hidden id of the clicked menu will be passed to the child component ,In the child component I need to call the API based on the parent component values .

Here I reproduced my issue in Stackblitz ,Please take a look and give me the solution to solve this issue.

https://stackblitz.com/edit/angular-bootstrap-carousel-dynamic2-dssqrc?file=app/child/child.component.ts

Rolfston answered 4/5, 2018 at 4:4 Comment(2)
please include the relevant code sections in the SO post.Nashbar
@pixelbits I have reproduced all my codes in stackblitz ,Please take a lookRolfston
W
1

I don't find the code that triggered the click events :(. Template variables are in the loop but are being used outside of it. I recommend an alternative solution, through properties in app.component. Fork in stackblitz here https://stackblitz.com/edit/angular-bootstrap-carousel-dynamic2-exbr5f?file=app%2Fapp.component.html

Woodham answered 4/5, 2018 at 5:3 Comment(5)
instead of taking clicked menu names ,I want to pass the menu's id to api from child component for that I have using hidden textbox ,If you help me to take that hidden textbox id values it will much helpful for meRolfston
I have posted the API calling in ngOnchanges ,Here I have facing an issue it always passing "this.C_code" values if I clicked on subcategories that values are changed but not passing to API ,Can you tell me Why it happensRolfston
ngOnChanges called in child component, if only @Input property value changed. If you clicked to same item several times, ngOnChanges not called.Woodham
I tried with different values but ngOnchanges always pass 100 (category id) to APIRolfston
Because in this example has only one category with code 100. It's Indian Spices category.Woodham

© 2022 - 2024 — McMap. All rights reserved.