Recently delving into the world of angular.js, I encountered an issue while trying to run a basic controller example.
The error message reads: [ng:areq] http://errors.angularjs.org/1.4.7/ng/areq?p0=Mycontroller&p1=not%20a%20function%2C%20got%20undefined at Error (native)
Here is the code snippet from index.html:
<!DOCTYPE html>
<html ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.7/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body ng-controller="Mycontroller">
<h1>{{message}}</h1>
</body>
</html>
And here's what is in script.js file:
var Mycontroller = function($scope){
$scope.message = "Hello Angular";
};
The output displays as follows:
{{message}}
Could someone help me identify where I have gone wrong?