Ng点击不是最新的?

时间:2016-08-17 16:15:29

标签: angularjs function button ionic-framework angularjs-ng-click

我有一些用户,并根据所选用户显示某些按钮。按钮的标题和标识位于来自ng-repeat的对象中。单击按钮时,它会将id传递给函数。作为测试,我将id传递给按钮标题中的按钮,并在函数中提醒传递的id。每当我切换到第二个用户时,标题中的id是正确的,但函数中的警报是前一个选定用户的id。这里有一些代码:

<div class="ShapeTableRow" ng-repeat="selfShape in employeeShapes.self">
    <button ng-if="selfShape.clickable === true" id="{{selfShape.shapeClass}}" class="button" ng-click="goToCriteria({{selfShape.id}});">{{selfShape.title}}{{selfShape.id}}</button>
</div>

$scope.goToCriteria = function (shapeIndex) {
    alert(shapeIndex);
};

因此ng-repeat对象基本上是最新的,但不是函数中提醒的值。

1 个答案:

答案 0 :(得分:0)

我找到了解决方案:Angularjs ng-click on repeat table row not working花括号确保id保持不变。