0

My Html is here: -->

        <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>
        <script type="text/javascript" src="app.js"></script>

        <title>Events Web</title>
    </head>
    <body ng-controller="LoginController">
        <p>{{name}}, world</p>
    </body>
    </html>

My app.js is here:

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

app.controller('LoginController',['$scope',
    function($scope){
        $scope.name = "100";
}]);

Can some one please help me with this? I tried a lot and couldn't find any mistake.

May be its a small one, but I couldn't find what's the issue

2
  • 1
    Did you write ng-app=LoginPage in your HTML? What is the issue you are facing? Any console errors in browser perhaps would be helpful. Commented May 27, 2016 at 5:26
  • There was no console errors. I added ng-app in <head> tag Commented May 27, 2016 at 5:32

1 Answer 1

4

You have forgot to add ng-app="LoginPage"

<html ng-app="LoginPage">
    <body ng-controller="LoginController">
         <p>{{name}}, world</p>
     </body>
</html>

See a basic example of Angularjs 1.3 setup - Sample

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

4 Comments

Can't I add ng-app in <head> ?
If you add ng-app in head then inside head tag your controller will be avaliable, not out side the head tag. body is outside of head tag.
No, because the <head> is not the container for controller. See this docs.angularjs.org/api/ng/directive/ngApp
ng-controller directive should be applied to a child element of ng-app directive.

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.