您的位置:首页 > Web前端 > AngularJS

angularJS之link函数对元素事件绑定或属性的操作

2015-11-07 15:23 696 查看
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="http://apps.bdimg.com/libs/angular.js/1.3.9/angular.min.js"></script>
</head>
<body >
<div><hello>22<hello></div>
</body>
<script>
var myApp=angular.module('myApp',[]);
myApp.directive('hello',function(){
return {
restrict:'AE',
template:'<div>hello angularJS</div>',
replace:true,
link:function(scope,element,attrs,controller){
console.log("hello angularjs");
element.on('mouseenter',function(){
console.log("link函数处理元素事件绑定或属性的操作");

});
element.on('mouseout',function(){
console.log("鼠标离开事件");
});
}
}
});
</script>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  angularjs 操作 函数