AngularJS实现根据变量改变动态加载模板的方法

时间:2016-11-04    点击:131   

本文实例讲述了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>

 希望本文所述对大家AngularJS程序设计有所帮助。

详解js运算符单竖杠“|”与“||”的用法和作用介绍
使用Ajax与服务器(JSON)通信实例
AngularJS过滤器filter用法实例分析
URL的参数中有加号传值变为空格的问题(URL特殊字符)
Angular页面间切换及传值的4种方法
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved