1. Element (E) : If we restrict custom directive with Element then directive execute only when a matching element is encountered.
2. Attribute (A): Only execute when a matching attribute is encountered.
3. Class (C): Directive execute only when a matching class is encoutered.
4. Comment (M): Directive execute only when a matching comment is encoutered.
Angular js Directive
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body ng-app="myApp">
<custom-directive></custom-directive>
<div custom-directive></div>
<script>
var app = angular.module("myApp", []);
app.directive("customDirective", function () {
return {
restrict: "A",
template: "<h4>Restict
the directive with attribute restiction!</h4>If you execute this programm
then custom-directive which is element is not execute because we restrict with
attribute "
};
});
</script>
</body>
</html>
Explanation & Enhancement
link: function (scope, element, attrs) { element.on("click", ".member-link", function () { }); }
ReplyDeleteI've been browsing online more than 4 hours today, yet I never found any interesting article like yours. It is pretty worth enough for me. In my view, if all site owners and bloggers made good content as you did, the internet will be much more useful than ever before. paypal login my account