<script src="http://code.angularjs.org/angular-1.0.1.min.js"></script>
<div ng-app="Ng">
<div supermanss></div>
<div enter="panel" leave>鼠标移入移出</div>
</div>
<script>
var ng = angular.module("Ng", []);
ng.directive("supermanss", function () {
return { restrict: "A", link: function () { alert("Hello")} };
})
ng.directive("enter", function(){return function (scope,element,attr) {
element.bind("mouseenter", function () {
// element.addClass("panel");
element.addClass(attr.enter);
})
}
})
ng.directive("leave", function () {
return function (scope, element, attr)
{
element.bind("mouseleave", function () {
// element.removeClass("panel");
element.removeClass(attr.enter);
})
}
})
</script>
AngularJS 02
最新推荐文章于 2019-11-07 18:48:51 发布