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

AngularJS ng-include directive

AngularJS Reference Manual

<!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 a 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 included in the same domain.

Syntax

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

ng-include directive as an element:

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

All HTML elements support this directive.

Parameter Value

ValueDescription
filenameFilename, a filename can be returned using an expression.
onloadOptional, the expression to be executed after the file is loaded.
autoscrollOptional, whether the included part is scrollable on the specified view.

AngularJS Reference Manual