写在前面

有时我们需要动态的创建一些标签,或者在收到服务端返回的json,创建一些标签然后找到页面上的元素,通过innerHTML写入到页面上面。angularjs也为我们提供了一种比较方便操作方式,ng-include。

ng-include:可以在html中包含html文件。

一个例子

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" ng-app="myapp">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script src="../Scripts/angular.min.js"></script>
<script>
var app = angular.module('myapp', []);
app.controller("myCtrl", function ($scope) {
//控制器
});
</script>
</head>
<body>
<div ng-controller="myCtrl">
<div ng-include="'test.html'"></div>
</div>
</body>
</html>

test.html

<h1>
这是个内容页面
</h1>

注意

ng-include包含的页面需要加上单引号。

结果

最新文章

  1. 从源码看Azkaban作业流下发过程
  2. zabbix 3.0快速安装简介(centos 6)
  3. PHP使用curl替代file_get_contents
  4. 解决uploadify多图片上传部分图片丢失,且不提示任何错误的问题
  5. Dell R410 broadcom网卡驱动更新失败
  6. CSS之perspective
  7. (转)[Erlang 0080] RabbitMQ :VHost,Exchanges, Queues,Bindings and Channels
  8. 如何重载ComboBox 使其下拉按钮(带下箭头的)和下拉列表的垂直滚动条的宽度改变?(自绘ComboBox) [转]
  9. ./configure: error: the HTTP rewrite module requires the PCRE library
  10. iOS KVO &amp; KVC
  11. 使用jQuery实现tag便签去重效果
  12. HTML5之画布的拖拽/拖放
  13. JVM 几个重要的参数
  14. Django项目实践4 - Django站点管理(后台管理员)
  15. python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告
  16. SQL-47 如何获取emp_v和employees有相同的数据?
  17. Java集合之HashSet源码分析
  18. 浅谈JS的作用域链(三)
  19. CSS的overflow属性介绍
  20. git基础命令。

热门文章

  1. [日常训练]FJ省夏令营day1
  2. 【bzoj2818】 Gcd
  3. 微信小程序一步步搭建商城系列-01-开篇
  4. BZOJ1057 [ZJOI2007]棋盘制作
  5. php Unable to find the wrapper &quot;https&quot;
  6. 获取exe目录
  7. [iOS 图像处理相关]
  8. POJ 2559 Largest Rectangle in a Histogram(单调栈)
  9. hdu 2010 - 水仙花数
  10. iOS - 基础面试知识