Angularjs ng-include Instruction
Angularjs instance
Include HTML file:
<!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>
Run Result:
MyFile.htm file Title
This text comes from the contained file myfile.htm!
Definitions and usage
The ng-include directive is used to include an external HTML file.
The contained content will be the child node of the specified element.
The value of the ng-include property can be an expression that returns a filename.
By default, included files need to be included under the same domain name.
Grammar
<element ng-include= "filename" onload= "expression" autoscroll= "expression" ></element>
Ng-include directives are used as elements:
<ng-include src= "filename" onload= "expression" autoscroll= "expression" ></ng-include>
All HTML elements support this directive.
Parameter values
value |
Description |
FileName |
File name, you can use an expression to return the file name. |
OnLoad |
Optionally, an expression that executes after the file is loaded. |
AutoScroll |
Optionally, the included portion is scrollable on the specified view. |
The above is the Angularjs ng-include instruction of knowledge collation, follow-up continue to add.