I'm reading
https://www.syncfusion.com/resources/techportal/ebooks/angularjs
The third sample from the book on a basic usage fo the controller won't work for me:
JS:
function MyCtrl($scope) {
$scope.visible = true;
$scope.toggle = function() { $scope.visible = !$scope.visible; };
};
Html:
<html>
<head>
<script src="scripts/vendor/angular/angular.min.js"></script>
<script src="scripts/controllers/app.js"></script>
</head>
<body ng-app>
<div ng-controller="MyCtrl"> <button ng-click="toggle()">Toggle</button>
<p ng-show="visible">Hello World!</p>
</div>
</body>
</html>
Error:
[ng:areq] http://errors.angularjs.org/1.3.0-rc.4/ng/areq?p0=MyCtrl&p1=not%20a%20function%2C%20got%20undefined
Angular isn't happy with the controller, wonder if I'm using it right or the book is out of date? On Angular website I saw samples of much more sophisticated controller's declaration.