当我在我的代码中执行以下操作时
<pre>{{uploader.queue.indexOf(item)|json}}</pre>
我得到了我正在寻找的元素的索引但是如果我做这样的事情
removeAllFiles(uploader.queue.indexOf(项))
结果总是
-1
答案 0 :(得分:1)
试试这个
<强> Working Demo 强>
<强> HTML 强>
<div class="container" ng-app="main" ng-controller="Controller">
<div ng-repeat="uploader in uploaders">
<button ng-click="removeAllFiles(uploader.queue.indexOf(item))">{{uploader.queue.indexOf(item)|json}}
</button>
</div>
</div>
<强>脚本强>
angular.module('main', []);
// Main Controller
function Controller($scope) {
$scope.item = 'N';
$scope.uploaders = [{
clickable: true,
id:1,
queue: "ABC-Name"
}, {
clickable: false,
id:2,
queue: "XYZ-Name"
}, {
clickable: true,
id:3,
queue: "LMN-Name"
}];
$scope.removeAllFiles = function(item) {
console.log(item);
}
}