在我的模板中,值未重新加载 [英] In my template the values are not reloaded
问题描述
我是Angular的新手.我尝试将代码上传到Stackblitz以便在我调用动态模式时寻求帮助.我正在执行一个函数,希望在任何组件中调用该函数以生成动态弹出窗口,在其中可以动态更改弹出窗口的页眉,正文和页脚.
I am new in Angular. I tried to upload my code to Stackblitz to look for help when I call my dynamic modal. I am doing a function that I hope to call in any component to generate a dynamic popup in which I can dynamically change the header, body and footer of the popup.
当我从home组件调用它时,弹出窗口不会刷新我给它的值.我该如何解决?
The popup does not refresh the values I give it when I call it from the home component. How can i fix this?
这是我的代码:
https://stackblitz.com/edit/angular-qothyw
推荐答案
您正在为每个组件提供服务.这样做会为每个组件创建一个独立实例,该实例仅存在于该组件的范围内.删除组件中的 providers:[AppService]
并仅在模块中提供服务.那应该可以解决您的问题.
You are providing your service for each component. Doing so creates an independend instance for each component which exists only in the scope of that component. Remove the providers: [AppService]
in your components and just provide the service in your module. That should solve your problem.
这是正在工作的 stackblitz
这篇关于在我的模板中,值未重新加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!