javascript - AngularJS - ng-mouseover doesn't fire my controller function -


i trying call function when button moused-over. code should work, doesn't fire function defined in controller.

javascript code

angular.module("myapp", [])        .controller('myctrl', function($scope) {           $scope.alerthi = function() {             alert('hi');           };        }); 

html code

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <title>example - example-example72-production</title>    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script>  </head> <body ng-app="myapp">   <div ng-controller="myctrl">     <button ng-mouseover="alerthi()">       alert hi     </button>   </div> </body> </html> 

i have plunker

http://plnkr.co/edit/zyqui266hfsnvphctcpn?p=preview

any ideas? thanks!

your-code.js

angular.module("myapp", [])        .controller('myctrl', function($scope) {           $scope.alerthi = function() {             alert('hi');           };        }); 

you need load code:

<!doctype html> <html lang="en"> <head>   <meta charset="utf-8">   <title>example - example-example72-production</title>     <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.4.1/angular.min.js"></script>   <script scr="your-code.js"></script>   </head> <body ng-app="myapp">   <div ng-controller="myctrl">     <button ng-mouseover="alerthi()">       alert hi     </button>   </div> </body> </html> 

Comments