Gediminas Šukys
Gediminas Šukys

Reputation: 7391

Is not a function, got undefined

I'm trying to find a problem for over an hour. I got an error:

Error: Argument 'SimpleController' is not a function, got undefined

Does anyone know why SimpleController is undefined? Thanks!

    <!DOCTYPE html>
    <html ng-app>
    <body>
    <div ng-controller="SimpleController">
        <ul>
            <li ng-repeat="customer in customers">
                {{ customer.name }}
            </li>
        </ul>
    </div>   
    <script type="text/javascript"
            src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
    <script>
        function SimpleController($scope) {
            $scope.customers = [
                { name: 'Dave Jones', city: 'Kentucky' },
                { name: 'Mister X', :city: 'SF' }
            ];
        }
    </script>
    </body>
    </html>

Upvotes: 1

Views: 1957

Answers (2)

colllin
colllin

Reputation: 9779

Remove the : in front of :city:.

Working example: http://jsfiddle.net/colllin/aQHpb/

Upvotes: 2

Mark Meyer
Mark Meyer

Reputation: 3723

You have a typo in your array. Delete this colon and it'll work

$scope.customers = [
            { name: 'Dave Jones', city: 'Kentucky' },
            { name: 'Mister X', **:** city: 'SF' }
        ];

Upvotes: 5

Related Questions