English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-include instruction

AngularJS 参考手册

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js</script>
</head>
<body ng-app="">
<div ng-include="'myFile.htm'"></div>
</body>
</html>
Test and see ‹/›

Definition and usage

ng-include The directive is used to include external HTML files.

The included content will be as the child node of the specified element.

ng-include The value of the attribute can be an expression that returns a filename.

By default, the included files need to be in the same domain.

Syntax

   <element ng-include="filename" onload="expression" 
   autoscroll="expression" ></element>

ng-include 指令作为元素使用:

<ng-include src="filename" onload="expression"   autoscroll="expression" ></ng-include>

All HTML elements support this directive.

Parameter value

ValueDescription
filenameFilename, it can be used to return the filename with an expression.
onloadOptional, the expression to be executed after the file is loaded.
autoscrollOptional, whether the included parts can be scrolled in the specified view.

AngularJS 参考手册