我使用ng-repeat
模板自定义指令的范围内:传递参数到NG-点击指令,自定义指令
<li ng-repeat="image in images">
<img ng-src="{{image.url}}" ng-click="togglePhoto({{$index}})">
</li>
当源看起来像
<li ng-repeat="image in images" class="ng-scope">
<img ng-src="http://example.com/example.jpg" ng-click="togglePhoto(1)" src="http://example.com/example.jpg">
</li>
在页面上呈现
我有我的指令中定义的功能togglePhoto
。如果没有传入参数{{index}}
,它将起作用并调用该函数。通过索引,它不会触发。
如何获取点击进togglePhoto
函数的照片索引?
'togglePhoto(x)'是如何定义的? – zsong