Latest web development tutorials
 

AngularJS ng-include Directive


Example

Include HTML from an external file:

<div ng-include="'myFile.htm'"></div>
Try it Yourself »

Definition and Usage

The ng-include directive includes HTML from an external file.

The included content will be included as childnodes of the specified element.

The value of the ng-include attribute can also be an expression, returning a filename.

By default, the included file must be located on the same domain as the document.


Syntax

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

The ng-include directive can also be used as an element:

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

Supported by all HTML elements.


Parameter Values

Value Description
filename A filename, written with apostrophes, or an expression which returns a filename.
onload Optional. An expression to evaluate when the included file is loaded.
autoscroll Optional. Whether or not the included section should be able to scroll into a specific view.