The example in this article describes how AngularJS implements dynamic loading of templates based on variable changes. Share it with everyone for your reference, as follows:
directive:
return { restrict: 'E', replace: true, templateUrl: 'app/view/order.html', link: function (scope, element, attrs) { scope.Type = attrs.Type; } };
Template:
<div ng-switch on="item.Type"> <div ng-switch-when="1"><ng-include src="'views/1.html'"></ng-include></div> <div ng-switch-when="2"><ng-include src="'views/2.html'"></ng-include></div> <div ng-switch-when="3"><ng-include src="'views/3.html'"></ng-include></div> </div>
I hope this article will be helpful to everyone in AngularJS programming.