AngularJS ngRepeat 语法错误
AngularJS ngRepeat syntax error
使用 AngularJS v1.3.15
我收到一个奇怪的语法错误:
http://errors.angularjs.org/1.3.15/ngRepeat/iexp?p0=item%20asNaNtems
这是我的模板 (templateUrl):
<div class="context-menu" ng-if="showMenu">
<div class="context-menu-item" ng-repeat="item as items" ng-class="{disabled: item.isDisabled()}">
<a href="" ng-click="fire(item)">
<i class="fa" ng-class="item.getIcon()"></i> {{item.getName()}}
</a>
</div>
</div>
该指令在该指令的控制器函数中以 $scope.items = []
开头:
angular.module('app').directive('atContextMenu', [
function() {
return {
'templateUrl': '...',
'controller': function($scope, $element) {
$scope.items = [];
}
};
}
]);
正如 link 所说(如果您点击了 link),您得到了 syntax wrong。应该是 item in collection
:
ng-repeat="item in items"
使用 AngularJS v1.3.15
我收到一个奇怪的语法错误:
http://errors.angularjs.org/1.3.15/ngRepeat/iexp?p0=item%20asNaNtems
这是我的模板 (templateUrl):
<div class="context-menu" ng-if="showMenu">
<div class="context-menu-item" ng-repeat="item as items" ng-class="{disabled: item.isDisabled()}">
<a href="" ng-click="fire(item)">
<i class="fa" ng-class="item.getIcon()"></i> {{item.getName()}}
</a>
</div>
</div>
该指令在该指令的控制器函数中以 $scope.items = []
开头:
angular.module('app').directive('atContextMenu', [
function() {
return {
'templateUrl': '...',
'controller': function($scope, $element) {
$scope.items = [];
}
};
}
]);
正如 link 所说(如果您点击了 link),您得到了 syntax wrong。应该是 item in collection
:
ng-repeat="item in items"