I'm learning AngularJS. I tried with sample code, got error when I ran it. It's basic example I guess so. Wasn't sure of the error.
On FireFox when I tried with FireBug, it show MyController1 not a function.
Any help appreciated.
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js"></script>
</head>
<body ng-app="myapp">
<div ng-controller="MyController1">
<div ng-click="myData1.doClick()">Click here</div>
</div>
<script>
angular.module("myapp", [])
.controller("MyController1", function($scope) {
$scope.myData1 = {};
$scope.myData1.doClick = function() {
alert("clicked");
}
} );
</script>
<div ng-controller="MyController2" >
<div ng-click="myData.doClick($event)">Click here for Event Coordinates</div>
</div>
<script>
angular.module("myapp", [])
.controller("MyController2", function($scope) {
$scope.myData = {};
$scope.myData.doClick = function(event) {
alert("clicked: " + event.clientX + ", " + event.clientY);
}
} );
</script>
</body>
</html>