0

I am trying to run the example code given in Dave Wahlin's 60ish minutes of AngularJS but getting an error.

The error message is not very easy to understand.

<html ng-app>
    <head>
        <title></title>
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js" type="text/javascript"></script>

        <script type="text/javascript">
            function SimpleController($scope) {
                $scope.customers = [
                    {name: 'Dave', city: 'Phoenix'},
                    {name: 'Carol', city: 'Los Angeles'},
                    {name: 'Steve', city: 'Seattle'}
                ];
            }
        </script>
    </head>
    <body ng-controller="SimpleController">
        <div class="container" >
            <input type="text" ng-model="name" />
            <ul >
                <li ng-repeat="cust in customers| filter:name">{{cust.name}} - {{cust.city}}</li>
            </ul>
        </div>
    </body>
</html>

For some reason stackoverflow is not allowing the angularjs script I have which points to the CDN. Also, there is a body tag outside the div where i have placed ng-controller = "SimpleController"

1
  • 1
    What is the error message exactly? Commented Apr 14, 2015 at 14:02

1 Answer 1

0

I'm not familiar with the tutorial you're following (which could be outdated), but this simple example runs like this:

var myApp = angular.module('myApp',[]);

myApp.controller('SimpleController', ['$scope', function($scope) {
  $scope.customers = [
        { name: 'Dave', city: 'Phoenix' },
        { name: 'Carol', city: 'Los Angeles' },
        { name: 'Steve', city: 'Seattle' }
       ];
}]);

Here's a plunker: http://plnkr.co/edit/47MQDKbTJKCh2iXE7QTn

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.