我有一个对表格中的列进行排序的角度指令。在 1.20 版本之前,这可以工作,但在升级到 1.20 之后,我收到以下错误。有谁知道出了什么问题?
错误:[$parse:isecprv] http://errors.angularjs.org/undefined/ $parse/isecprv?p0=_sort()
app.directive('sorted', function () {
return {
scope: true,
transclude: true,
template: '<a href="#/" ng-click="_sort()" ng-transclude=""></a>' +
'<span class="sortArrow" ng-show="show_sort_icon(true)">▼</span>' +
'<span class="sortArrow" ng-show="show_sort_icon(false)">▲</span>',
controller: function ($scope, $element, $attrs) {
$scope._sort = function () {
$scope.model.sort($attrs.sorted);
};
$scope.show_sort_icon = function (is_desc) {
return ($scope.model.sidx == $attrs.sorted) && ($scope.model.is_desc == is_desc);
};
}
};
});
用法:
<table>
<thead>
<tr>
<th sorted="something">Something</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="item in model.items">
<td>{{item.something}}</td>
</tr>
</tbody>
</table>