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. SAP 常用业务数据表设计

    表的要求表中使用的字段请尽量参照各模块的SAP字段标准使用习惯:  例:"ZXSLRZX销售组织对应的利润中心"中的销售组织应该使用VKORG.利润中心应该使用PRCTR.根据表的 ...

  2. Vim编辑器基础

    Vim编辑器基础 vi:Visual Interface vim:VI iMproved Vim模式 1.编辑模式(命令模式) 只能下达命令,不能键入字符 2.输入模式 键入字符 3.末行模式 左下角 ...

  3. 【转】centos中service命令与/etc/init.d的关系以及centos7的变化

    centos中service命令与/etc/init.d的关系 service httpd start 其实是启动了存放在/etc/init.d目录下的脚本. 但是centos7的服务管理改规则了.C ...

  4. 使用TensorFlow的卷积神经网络识别手写数字(3)-识别篇

    from PIL import Image import numpy as np import tensorflow as tf import time bShowAccuracy = True # ...

  5. for_each_node(node)

    遍历各个pg_data_t节点. 1.定义在include/linux/nodemask.h中 /* * Bitmasks that are kept for all the nodes. */ en ...

  6. golang(go语言)调试和查看gc信息,以及gc信息解析

    这里记录一下调试golang gc的方法 启用gc打印: # GODEBUG=gctrace=1 go run ./main.go 程序启动后gc将打印如下信息: gc 65 @16.996s 0%: ...

  7. poj 3614 伪素数问题

    题意:1.p不是素数 2.(a^p)%p=a 输出yes  不满足输出no 思路: 判断素数问题,直接暴力判断 bool is_prime(int n) {  for(int i=2;i*i<= ...

  8. BZOJ 4985: 评分

    二分答案 >=key的记为1 f[i]表示令i位置为1所需要的最少的1的个数 队列模拟 #include<cstdio> #include<algorithm> usin ...

  9. HDU 5510 Bazinga KMP

    题意: 给\(n(1 \leq n \leq 500)\)个字符串,求一个最大的\(i\),使得存在一个\(S_{j}\)不是\(S_i\)的子串. 分析: 维护两个指针\(l,r\) 那么有两种情况 ...

  10. jmeter所有版本下载路径

    https://archive.apache.org/dist/jmeter/binaries/