ng-include可以作为标签或者属性来使用,作用是引入公用文件。

<div ng-include="'header.html'"></div>

注意里面的单引号不要漏了。

第二种使用方法,使用参数作为引用。

$scope.header = '/test/header.html';
<div ng-include="header"></div>

和angualer其他地方的参数使用不同,此处不需要添加双大括号{{}},直接使用就可以。

好了,下面是黑科技了。

以一个无限遍历目录树为例。

第一部分,页面内容部分

<div class="tree">
<i class="glyphicon glyphicon-folder-close"></i>
<a href="javascript:;" ng-right-click="editFolder($event, 0)">
<i></i>
<input type="hidden" value="0">
<span>{{sessionData.jobEnterprise.enterpriseName}}</span>
</a>
<!--<folder-tree current-folder="listData"></folder-tree>-->
<ul>
<li ng-repeat="node in listData" ng-include="'query.html'"> </li>
</ul>
</div>
<div class="right-content" ng-show="rightContent" ng-mouseleave="rightContent = false">
<ul>
<li class="right-content-item" ng-click="rightAdd()">新建</li>
<li class="right-content-item" ng-click="rightUpdata()">重命名</li>
<li class="right-content-item" ng-click="rightDelete()">删除</li>
</ul>
</div>
<div class="folder-text" ng-show="folderText"><input ng-model="folderValue" type="text"><button class="btn btnn-success" ng-click="rightAddOk()">确定</button><button class="btn btnn-info" ng-click="folderText = false"></button></div>
</div>

第二部分,模板部分

<script type="text/ng-template" id="query.html">
<a href="javascript:;" ng-right-click="editFolder($event, node)">
<i></i>
<input type="hidden" value="{{node.folderId}}">
<span>{{node.folderName}}</span>
</a>
<ul>
<li ng-repeat="node in node.childList" ng-include="'query.html'" ng-init="node = node.childList"> </li>
</ul>
</script>

此处当注意重点

 type="text/ng-template"

这是让ng-include优先选择本页模板的关键部分。

剩下的就是一些操作的修改了。

ng-include的更多相关文章

  1. Part 16 ng include directive in AngularJS

    ng-include directive is used to embed an HTML page into another HTML page. This technique is extreme ...

  2. IE兼容性问题汇总【持续更新中】

    问题:IE8/9不支持Array.indexOf 解决方案 if (!Array.prototype.indexOf) { Array.prototype.indexOf = function(elt ...

  3. AngularJS开发指南7:AngularJS本地化,国际化,以及兼容IE低版本浏览器

    AngularJS本地化,国际化 国际化,简写为i18n,指的是使产品快速适应不同语言和文化. 本地化,简称l10n,是指使产品在特定文化和语言市场中可用. 对开发者来说,国际化一个应用意味着将所有的 ...

  4. angularJs项目实战!02:前端的页面分解与组装

    自从上一篇文章到现在已经有将近一个月的时间,我将精力放在了前端页面分解与组装,和angularjs如何与jquery.bootstrap.D3等一系列其他类库结合使用的经验总结上.由于公司新招了一些员 ...

  5. Hex Dump In Many Programming Languages

    Hex Dump In Many Programming Languages See also: ArraySumInManyProgrammingLanguages, CounterInManyPr ...

  6. AngularJs学习笔记--IE Compatibility 兼容老版本IE

    原版地址:http://docs.angularjs.org/guide/ie Internet Explorer Compatibility 一.总括 这文章描述Internet Explorer( ...

  7. angularjs 手动启动

    谷歌推的javascript框架angulajs相当火热,由于新项目的缘故,最近一直看angularjs.在看的时候,一直有个疑问,angularjs 核心依赖于DI(依赖注入).常用的方法是在页面的 ...

  8. Angular js ie 7,8 兼容性

    Angularjs  官网有云: 1)在html 里面 ,有ng-app 的标签里需要定义个id ,id='ng-app'; 2)ie 7及以下版本需要json2.js或json3.js,主要用来解析 ...

  9. angular.js,IE7,8,9兼容性的处理

    转........... 这段时间详细了解了谷歌新出的MVVM框架angular.js,并直接在本人所从事的项目中使用了.但是使用新东西都是有风险的,这不,采用了新框架的页面IE7,8各种显示不出来… ...

  10. Flume NG Getting Started(Flume NG 新手入门指南)

    Flume NG Getting Started(Flume NG 新手入门指南)翻译 新手入门 Flume NG是什么? 有什么改变? 获得Flume NG 从源码构建 配置 flume-ng全局选 ...

随机推荐

  1. [BZOJ] 1441 Min

    题意:给一堆数ai,求S=Σxiai,使得S最小且为正整数 根据裴蜀定理,一定存在ax+by=gcd(a,b),同理可以推广到n个整数 也就是说,在不考虑正负的情况下,所有数的gcd就是所求 #inc ...

  2. Beyond Compare 4 30天试用期后,破解方法

    Beyond Compare 4 30天试用期后,破解方法. 方法一:在安装目录下找到文件BCUnrar.dll,比如:D:\software\Beyond Compare 4,重命名该文件即可. 重 ...

  3. guava笔记

    ​guava是在原先google-collection 的基础上发展过来的,是一个比较优秀的外部开源包,最近项目中使用的比较多,列举一些点.刚刚接触就被guava吸引了... ​    ​这个是gua ...

  4. 同一条sql在mysql5.6和5.7版本遇到的问题。

    之前用的是mysql 5.6版本,执行select * from table group by colunm 是可以出结果的, 但是切换的5.7版本,这条sql就报错, Expression #1 o ...

  5. Linux任务计划、周期性任务执行

    Linux任务计划.周期性任务执行 周期性任务执行: cron 守护进程(crond):服务,不间断地运行于后台 # service crond {start|stop|status|restart} ...

  6. ATM源码

    package atm;//张秋亮,信1705-3,20173529 public class Account { private String accountID; private String a ...

  7. day04 装饰器 迭代器&生成器 Json & pickle 数据序列化 内置函数

    回顾下上次的内容 转码过程: 先decode  为 Unicode(万国码 ) 然后encode 成需要的格式     3.0 默认是Unicode  不是UTF-8 所以不需要指定  如果非要转为U ...

  8. python面试题解析(前端、框架和其他)

    答: HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的方式,适用于分布式超媒体信息系统.它于1990年提出,经过几年的使用与发展,得到不断地完善和扩展.目前在WWW中使用的是HTTP/1. ...

  9. 前端 五——ajax

    内容概要: 1.ajax的特点 2.基于JS的ajax 3.基于jQuery的ajax 1.特点: 局部刷新 异步传送(交互) 缺点: (1)无形中向服务器发送的请求次数太多,导致服务器压力增大. ( ...

  10. 【转】LAMP网站架构方案分析【精辟】

    [转]LAMP网站架构方案分析[精辟] http://www.cnblogs.com/mo-beifeng/archive/2011/09/13/2175197.html Xubuntu下LAMP环境 ...