Index.html:
<! DOCTYPE html>
Other.html:
<div> I am the other file {{name}}</div>
Index.js:
var myApp = angular.module (' MyApp ', [],[' $compileProvider ', function ($compileProvider) { $ Compileprovider.directive (' Customtags ', function () { return { restrict: "eCAM", templateurl: ' temp/ Other.html ', replace:true //If this configuration is true, the replacement instruction element if False or not specified appends the current instruction to the inside of the element}} ]) . directive (' CustomTags2 ', function () { return{ restrict: "eCAM", templateurl: "CustomTags2", // corresponding to type= "text/ng-template" specifies the tag ID of script (replace:true} }) . Controller (' Firstcontroller ', [' $scope ', function ($scope) { $scope. Name = "Zhang San";//Assignment }]);
Operation Result:
AngularJS1 notes-(10)-Custom directives (Templateurl properties)