1
我使用esvit「ngTable。顯示一大堆數據。ngTable更新ngClass導致錯誤
但是當我嘗試添加納克級(FN)。首先渲染它的工作原理(顯示信息類),但是當我操縱數據(當我改變user
屬性得主(從ng-click="(toggleWinner(user))"
),它拋出一個錯誤,而不是更新類的
ngTable:
<div ng-show="(answers).length > 0">
<table ng-table="tableParams" template-pagination="custom/pager" class="table table-striped table-bordered table-hover" style="margin-top: 12px;">
<tr style="cursor:pointer;" ng-click="toggleWinner(user);" ng-repeat="user in $data" ng-class="getClass(user)">
<td data-title="'Bruger'" sortable="'name'">{{user.name}}</td>
<td data-title="'Email'" sortable="'email'">{{user.email}}</td>
<td data-title="'Firma'" sortable="'company'">{{user.company}}</td>
<td data-title="'Mobil'" sortable="'mobile'">{{user.mobile}}</td>
<td data-title="'Vundet dato'" >{{getPreviousWinnings(user.email)}}</td>
<td data-title="'Udvælg Vinder'" >
<span ng-show="user.winner == true" class="glyphicon glyphicon-ok" style="color:darkgreen"></span>
</td>
</tr>
</table>
</div>
的getClass(用戶):
$scope.getClass = function(user) {
if (user.winner) {
return "success";
} else if ($scope.getPreviousWinnings(user.email).length > 0) {
return "info";
} else {
return "";
}
};
我希望你能幫助,並感謝您考慮看看
錯誤描述:
TypeError: undefined is not a function
at Object.k [as fn] (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:136:370)
at h.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:106:311)
at h.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:109:287)
at HTMLTableRowElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js:189:372)
at HTMLTableRowElement.m.event.dispatch (local/js/libs/jquery-1.11.1.min.js:3:8436)
at HTMLTableRowElement.r.handle (local/js/libs/jquery-1.11.1.min.js:3:5146)
這是什麼意思'操縱'數據它意味着排序\過濾?我認爲問題'答案隱藏在操作過程中))你可以提供plunk錯誤再現在時間 – 2014-10-28 09:27:05
操縱,因爲當我改變屬性贏家'用戶'(從'NG點擊=「(toggleWinner(用戶))」'。我會嘗試,使後來普拉克重現 – 2014-10-28 09:54:12
@KostiaMololkin謝謝,我想通了,由於plnkr :) – 2014-10-28 13:50:41