AngularJS在Collapsibile指令中通知有关崩溃事件的指令的最佳方法

[英]AngularJS best way to notify a directive inside a Collapsibile directive about a collapse event


I have a custom collapsible directive using an isolated scope, that contains other directives using as well isolated scope, that should react to the collapse event (collapse just change the height) What is the preferred way for a container to notify a contained element that the collapse status is changed?

我有一个使用隔离范围的自定义可折叠指令,其中包含使用隔离范围的其他指令,应该对崩溃事件做出反应(折叠只是更改高度)容器通知包含元素的首选方法是什么崩溃状态改变了?

Thanks

1 个解决方案

#1


2  

You can broadcast an event from your container directive when the state changes and listen for that event on every child directive.

您可以在状态更改时从容器指令广播事件,并在每个子指令上侦听该事件。

From your parent directive :

从您的父指令:

scope.$broadcast(name, args);

On all your child directives :

在你所有的孩子指令:

scope.$on(name, listener);

Look AngularJS scope documentation for more informations on how to use events.

查看AngularJS范围文档,了解有关如何使用事件的更多信息。

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2015/01/29/71d725c77c7f33f0c7a3e068776f0dc0.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告