I am learning AngularJs. I am creating my first application on Plunker but it fails to initialize the controller. what am i missing exactly?

Here is the link of my plunker project

    <html ng-app>

<head>
  <script data-require="angular.js@*" data-semver="1.4.0-beta.1" src="https://code.angularjs.org/1.4.0-beta.1/angular.js"></script>
  <link rel="stylesheet" href="style.css" />
  <script src="script.js"></script>
</head>

<body ng-controller="testcontroller">
  <h1>Hello {{message}}</h1>
</body>

</html>

var testcontroller = function($scope) {
  $scope.message = "world";
};
share|improve this question
1  
<html ng-app>.. here you need to give app name.. – Ved Jan 23 '15 at 6:17
    
That is not necessary as long as i m not using modules – Tuscan Jan 23 '15 at 6:19
    
You need it man.. go to documentation of AngulaJS – Ved Jan 23 '15 at 6:22
    
I got it. using ng-App without module name was working flawlessly with previous releases like 1.3.0-beta.5 but Angular no longer supports this functionality – Tuscan Jan 23 '15 at 6:30

Here is Plunkr

Declare ng-app="myApp"

You are defining controller in wrong way

angular.module('myApp',[])
.controller('testcontroller', function($scope){
  $scope.message="world";
});
share|improve this answer
    
is it mandatory to assign a module for the application? because i have seen many examples working with only ng-app – Tuscan Jan 23 '15 at 6:22
    
modular approach separates the code better way docs.angularjs.org/guide/module – Pankaj Parkar Jan 23 '15 at 6:24
    
@Tuscan if it does solve your problem then mark it as correct. Thanks :) – Pankaj Parkar Jun 26 '15 at 17:15

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.