1、HTML源码
- <!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>
2、angularjs源码
- 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("鼠标进入...");
- });
- }
- }
- });
3、执行效果
页面:
当鼠标移动到页面上后,console打出的日志: