(PCC)::[How-to-use-A-Directive-with-restrictions-in-AngularJS]::[angularjs]
<!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> <body ng-app="myApp"> <w3-test-directive></w3-test-directive> <div w3-test-directive></div> <script> var app = angular.module("myApp", []); app.directive("w3TestDirective", function() { return { restrict : "A", template : "<h1>Made by a directive!</h1>" }; }); </script> <p><strong>Note:</strong> By setting the <strong>restrict</strong> property to "A", only the HTML element with the "w3-test-directive" attribute has invoked the directive.</p> </body> </html>
Note: By setting the restrict property to "A", only the HTML element with the "w3-test-directive" attribute has invoked the directive.