[Angularjs]ng-include 包含
2024-08-21 04:41:02
写在前面
有时我们需要动态的创建一些标签,或者在收到服务端返回的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包含的页面需要加上单引号。
结果
最新文章
- 从源码看Azkaban作业流下发过程
- zabbix 3.0快速安装简介(centos 6)
- PHP使用curl替代file_get_contents
- 解决uploadify多图片上传部分图片丢失,且不提示任何错误的问题
- Dell R410 broadcom网卡驱动更新失败
- CSS之perspective
- (转)[Erlang 0080] RabbitMQ :VHost,Exchanges, Queues,Bindings and Channels
- 如何重载ComboBox 使其下拉按钮(带下箭头的)和下拉列表的垂直滚动条的宽度改变?(自绘ComboBox) [转]
- ./configure: error: the HTTP rewrite module requires the PCRE library
- iOS KVO &; KVC
- 使用jQuery实现tag便签去重效果
- HTML5之画布的拖拽/拖放
- JVM 几个重要的参数
- Django项目实践4 - Django站点管理(后台管理员)
- python+requests+excel+unittest+ddt接口自动化数据驱动并生成html报告
- SQL-47 如何获取emp_v和employees有相同的数据?
- Java集合之HashSet源码分析
- 浅谈JS的作用域链(三)
- CSS的overflow属性介绍
- git基础命令。