【发布时间】:2016-10-27 12:01:09
【问题描述】:
在html中,我写如下:
<div ng-controller="cxController">
<my-dir test-data="testdata"></my-dir>
</div>
在cxController中,我写如下:
$scope.testdata={
spanInfo:{},
buttonInfo:{}
};
$scope.click1=function(){};
$scope.click2=function(){};
$scope.click3=function(){};
在指令中,有一些跨度和按钮。并且没有设置按钮编号,我需要使用 ng-repeat 来编写它。但是按钮有点击功能:click1,click2,click3等等。如何在指令中调用函数 click1,click2...?
告诉指令在buttonInfo中有一些这样的函数?
$scope.testdata={
spanInfo:{},
buttonInfo:{
{click:$scope.click1}
{click:$scope.click2}
}
};
【问题讨论】:
-
指令有什么
scope属性?另外,为什么只使用一种接受 "index" 参数的方法?
标签: angularjs angularjs-directive