Prev Demo
AngularJS
>
Restricting Custom Directive
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script> </head> <body> <script> var app = angular.module("app", []) .controller("CustomDirectiveController", function ($scope) { $scope.username = "SheoNarayan"; $scope.address = "Hyderabad, India"; }); app.directive('myCustomRestrict', function () { return { restrict : 'AEC', template: ' UserName: {{ username }}, Address: {{ address }}' }; }); </script> <div ng-app="app" ng-controller="CustomDirectiveController"> <h2>Restricting custom directive</h2> <div><b>Attribute:</b> <span my-custom-restrict></span></div> <div><b>Element:</b> <my-custom-restrict></my-custom-restrict></div> <div><b>Class:</b> <span class="my-custom-restrict"></span></div> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output