简体   繁体   English

AngularJS - 在一个页面上有更多相同的指令,具有自己的状态

[英]AngularJS - more of the same directives on one page with its own state

in ralation to the question Call method in directive controller from other controller . 从通向其他控制器的指令控制器中的调用方法的问题。

How can I put more than one independent directives of the same type on the page? 如何在页面上放置多个相同类型的独立指令? Because of its common API (singleton) is the state shared. 因为它的共同API(singleton)是共享的状态。 So if I will place two same directives there both will reflect one instance of API and obviously same state. 因此,如果我将两个相同的指令放在那里,它们将反映一个API的实例,并且显然是相同的状态。

I think what you're talking about is isolating the scope of a directive, the relevant documentation is here . 我认为你所说的是隔离指令的范围,相关文档就在这里 This may be as simple as scope: true , which makes an isolated scope for the directive which inherits. 这可能就像scope: true一样简单,它为继承的指令创建了一个独立的范围。 You can read about that here . 你可以在这里阅读。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM