本文實(shí)例講述了AngularJS實(shí)現(xiàn)根據(jù)變量改變動態(tài)加載模板的方法。分享給大家供大家參考,具體如下:
directive:
return { restrict: 'E', replace: true, templateUrl: 'app/view/order.html', link: function (scope, element, attrs) { scope.Type = attrs.Type; }};模板:
<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>
希望本文所述對大家AngularJS程序設(shè)計(jì)有所幫助。
新聞熱點(diǎn)
疑難解答