我想在component 1的帮助下打开或关闭另一个模块中的modals。但目前我无法访问该组件中modals的modalRef,以便我可以关闭/打开它。
假设这个场景
单模块
<component1></component1>
另一个模块这个模块有多个组件,每个组件都有模式,我需要根据组件1的条件显示或隐藏它。
<component2> //have ng bootstrap modal in it </component2>
<component3> //have ng bootstrap modal in it </component3>
<component4> //have ng bootstrap modal in it </component4>
<component5> //have ng bootstrap modal in it </component5>
<component6> //have ng bootstrap modal in it </component6>
目前我只是把一个隐藏的按钮放在该模块中,然后使用来自另一个组件的JavaScript单击它,我知道这不是一个好的方法,所以我希望有人给我一些调用这些模态的方法,或者告诉我在设计中是否有什么需要改变的。
据我所知,我认为服务将很好地做到这一点。但在改变设计之前,我想听听别人的意见。谢谢
https://stackoverflow.com/questions/46792291
复制相似问题