0

I am learning angularjs & facing error with angularjs I am trying to create a simple angular module getting error but sample controller function working ok without mudule I write the same code of video where from I am learning

Here is code

<!DOCTYPE html>
<html ng-app="demoApp">
<head>
    <title>
        Angular js
    </title>
</head>
<body>
<div class="containers" ng-controller="simpleController">
<input type="text" ng-model="name">
    <ul>
        <li ng-repeat="cust in customers | filter: name" | orderBy:'city'>{{ cust.name | uppercase}} - {{ cust.city | lowercase}}</li>
    </ul>
</div>
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript">
var demoApp = angular.module('demoApp'. []);
    function simpleController ($scope) {
        $scope.customers = [
        {name:'Dinesh', city:'Delhi'},
        {name:'Hansa', city:'Rajasthan'},
        {name:'Manju', city:'Rajasthan'},
        {name:'Mukesh', city:'Rajasthan'},
        {name:'Naresh', city:'Lahor'}
        ];
    }
    demoApp.controller('simpleController', simpleController);
</script>
</body>
</body>
</html>

but my app not work properly, display error like below enter image description here

Now my this question is solve this code is working with AngularJS v1.2.28 but same code not work with AngularJS v1.5.5 Thanks for help in advance

1
  • with the answer app is working, it work with AngularJS v1.2.28 but not work with latest AngularJS v1.5.5,I attached error with question Commented Apr 24, 2016 at 6:41

4 Answers 4

2

var demoApp = angular.module('demoApp'. []);

It should be

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

A comma instead of a period. Just a syntax error :)

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

Comments

1

Everything is ok
except angular.module('demoApp'. []),
must be angular.module('demoApp', []) - comma instead of dot, and be more attentive

<script type="text/javascript">
var demoApp = angular.module('demoApp'. []); //REPLACE DOT WITH COMMA
    function simpleController ($scope) {
        $scope.customers = [
        {name:'Dinesh', city:'Delhi'},
        {name:'Hansa', city:'Rajasthan'},
        {name:'Manju', city:'Rajasthan'},
        {name:'Mukesh', city:'Rajasthan'},
        {name:'Naresh', city:'Lahor'}
        ];
    }
    demoApp.controller('simpleController', simpleController);
</script>

Comments

1

In addition to the previous answers, I don't see you referencing the ng-app directive in your HTML so that should be in your body tag like this: body ng-app="demoApp"

1 Comment

he has used the ng-app directive on the HTML tag.
0

Change this

angular.module('demoApp'. []),
must be angular.module('demoApp', []) - comma instead of dot

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.