[英]Angular 4 : Call AppComponent Method from Another Component
I have a logout bouton in shared page, but i want to call logout method after clicked. 我在共享页面中有注销按钮,但单击后要调用注销方法。 the implementation of my logout function is in app.comoponent.ts 我的注销功能的实现在app.comoponent.ts中
can anyone help? 有人可以帮忙吗?
You need to make use of Shared service here. 您需要在此处使用共享服务。 Have your method implemented in a shared service and call the method from your login and shared component. 在共享服务中实现您的方法,然后从您的登录和共享组件中调用该方法。
There are couple solutions to this question. 这个问题有几种解决方案。
1.) You have to follow this steps: 1.)您必须遵循以下步骤:
2.) You have to follow this steps and Correct one: 2.)您必须按照以下步骤操作并更正一个:
谢谢大家,我只是将登录按钮移动到新的标头组件,并将隐含内容移至header.comoponent.ts
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.