angularjs 根据变量改变 动态加载模板

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>
上一篇:ADs系列之通用数据解析服务GAS(即将开源)


下一篇:angular源码分析:$compile服务——directive他妈