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

Nikson
  • 900
  • 2
  • 21
  • 51

1 Answers1

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

M.Octavio
  • 1,780
  • 2
  • 25
  • 39
Abylay
  • 344
  • 2
  • 11
  • 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 me – Nikson May 04 '18 at 05:08
  • 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 happens – Nikson May 04 '18 at 05:30
  • ngOnChanges called in child component, if only @Input property value changed. If you clicked to same item several times, ngOnChanges not called. – Abylay May 04 '18 at 05:40
  • I tried with different values but ngOnchanges always pass 100 (category id) to API – Nikson May 04 '18 at 05:43
  • Because in this example has only one category with code 100. It's Indian Spices category. – Abylay May 04 '18 at 05:46