AngularJS ng-include directive
AngularJS instance
Contains HTML files:
<!DOCTYPE html><html><head><meta charset="utf-8"><script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script></head><body ng-app=""><div ng-include="'myFile.htm'"></div></body></html>
Running results:
myFile.htm file title
This text comes from the included file myFile.htm!
Definition and usage
The ng-include directive is used to include external HTML files.
The content contained will be used as a child of the specified element.
The value of the ng-include property can be an expression that returns a file name.
By default, included files need to be included under the same domain name.
grammar
<element ng-include="filename" onload="expression" autoscroll="expression" ></element>
The ng-include directive is used as an element:
<ng-include src="filename" onload="expression" autoscroll="expression" ></ng-include>
All HTML elements support this directive.
Parameter value
| value | describe |
|---|---|
| filename | File name, you can use expressions to return the file name. |
| onload | Optional, an expression executed after the file is loaded. |
| autoscroll | Optional, whether the included part can be scrollable on the specified view. |
The above is a summary of the knowledge of AngularJS ng-include directives, and will be supplemented later.