Prev Demo
AngularJS
>
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('myCustom', function () { return { template: ' UserName: {{ username }}, Address: {{ address }}' }; }); </script> <div ng-app="app" ng-controller="CustomDirectiveController"> <p> <b>Using bind:</b> {{ username + ', ' + address }}</p> <p> <b>Using directive :</b> <span my-custom></span></p> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output