Prev Demo
AngularJS
>
Function With Templateurl
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> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet" /> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> </head> <body> <script> var app = angular.module("app", []) .controller("CustomDirectiveController", function ($scope) { $scope.username = "SheoNarayan"; $scope.address = "Hyderabad, India"; }); app.directive('myCustomUrlFunction', function () { return { templateUrl: function (element, attribute) { return '/DemoSupportingFiles/angular-MyView' + attribute.number + '.html'; } }; }); </script> <div ng-app="app" ng-controller="CustomDirectiveController"> <h2>function with templateUrl</h2> <div my-custom-url-function number="1"></div> <div my-custom-url-function number="2"></div> </div> </body> </html>
Note: We DO NOT save your trial code in our database.
Output