2
我创建了一个叫做modalDialog的指令,它基本上就是一个模态对话框。它采用transclude,所以后来我能做到这一点在我的代码:我可以为指令的不同实例更改指令的控制器吗?
<div modal-dialog id="dialog" dialog-title="This is my Dialog">
...
here goes the content of the dialog
</div>
我想在我的应用程序的不同位置使用此指令,并针对不同的目的。对话框的内容自然会有所不同,所以有办法将Controller传递给指令是非常好的,就像我传递对话标题或任何其他参数一样。
我想过在一个div中包装模态对话框,并在其上设置了一个控制器。像这样:
<div ng-controller="ThisInstanceController">
<div modal-dialog id="dialog" dialog-title="This is my Dialog">
...
here goes the content of the dialog
</div>
</div>
但我不太喜欢它。有没有更好的方法来做到这一点?