I am new to Angular JS and I am trying some examples... But I get a very weird exception when I try to load my app...
Here is my angular JS code:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
<script src="JS/Controllers.js"></script>
<body ng-app="myapp">
<div ng-controller="HelloController">
<h2>Hello {{helloTo.title}} !</h2>
</div>
<div ng-controller="MyController" >
<span ng-show="myData.showIt"></span>
<span ng-hide="myData.showIt"></span>
</div>
</body>
Here is my controller code :
angular.module("myapp", []).controller("HelloController", function($scope) {
$scope.helloTo = {};
$scope.helloTo.title = "Test";
} );
angular.module("myapp1", []).controller("MyController", function($scope) {
$scope.myData = {};
$scope.myData.showIt = true;
});
Error logged by firebug: Error: [ng:areq] http://errors.angularjs.org/1.2.5/ng/areq?p0=MyController&p1=not%20a%20function%2C%20got%20undefined https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js Line 83
I am using angular js version 1.2.5...
myapp
and one calledmyapp2
. This is whyMyController
can't be found. – Callum Linington