一、HTML源碼javascript
<!doctype html> <html ng-app="MyModule"> <head> <meta charset="utf-8"> </head> <body> <hello></hello> </body> <script src="../framework/angular-1.3.0.14/angular.js"></script> <script src="HelloAngularLink.js"></script> </html>
二、angularjs源碼html
var myModule = angular.module("MyModule", []); myModule.directive("hello", function() { return { restrict: 'E', template: '<div>Hi everyone!</div>', replace: true, link: function(scope, el, attrs, controller) { //console.log("<hello>...link..."); el.on("mouseenter", function() { console.log("鼠標進入..."); }); } } });
三、執行效果java
頁面:angularjs
當鼠標移動到頁面上後,console打出的日誌:app