ngOnChanges在Angular4中不起作用 [英] ngOnChanges not working in Angular4

查看:241
本文介绍了ngOnChanges在Angular4中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我不是第一个提出这个问题的人,并且我已经尝试过Stackoverflow上这么多帖子的解决方案,但是对我没有帮助.

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 .

当用户单击那些菜单时,我的父组件中有一个手风琴菜单,单击菜单的隐藏ID将传递给子组件,在子组件中,我需要基于父组件值调用API

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 .

这里,我在Stackblitz中转载了我的问题,请看一下并给我解决该问题的解决方案.

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

推荐答案

我找不到触发点击事件的代码:(.模板变量在循环中,但在循环之外使用.我建议使用另一种方法解决方案,方法是通过app.component中的属性.在这里将 https://stackblitz.com/edit/angular-bootstrap-carousel-dynamic2-exbr5f?file=app%2Fapp.component.html

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

这篇关于ngOnChanges在Angular4中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆