0
我已经编写了这段代码。但是当我点击图像时,它被称为三次。它应该被称为foo()方法一次。你有什么想法吗?如何在angular的ng-repeat中避免多次调用方法
<div ng-controller="photoCtrl">
<img ng-src="{{currentImg.path}}" class="current-img"></img>
<p>
<ul>
<li ng-repeat="image in images" class="thumb-list">
<img ng-src={{image.path}}/ class="thumb" ng-click={{foo()}}></img>
</li>
</ul>
</div>
PhotoCtrl在这里...
var photoCtrl = function($scope){
$scope.images = [
{"path":"img/a.jpeg"},
{"path":"img/b.jpeg"},
{"path":"img/c.jpeg"}
];
$scope.currentImg = _.first($scope.images);
$scope.foo = function(){
console.log("Called");
};
$scope.setCurrentImg = function(item){
console.log("callellellellellle");
};
};
非常感谢。有用。 – nobinobiru