BoxMan0617
BoxMan0617

Reputation: 140

AngularJS ngRepeat syntax error

Using AngularJS v1.3.15

I am getting a weird syntax error:

http://errors.angularjs.org/1.3.15/ngRepeat/iexp?p0=item%20asNaNtems

This is my template (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>

The directive starts with a $scope.items = [] in the controller function of that directive:

angular.module('app').directive('atContextMenu', [
    function() {
        return {
            'templateUrl': '...',
            'controller': function($scope, $element) {
                $scope.items = [];
            }
        };
    }
]);

Upvotes: 1

Views: 944

Answers (1)

PSL
PSL

Reputation: 123739

As the link says (if you have clicked on the link) you got the syntax wrong. It should be item in collection:

ng-repeat="item in items"

Upvotes: 5

Related Questions