AngularJS Basic ng include Simple Example
- 2021-07-07 06:08:01
- OfStack
AngularJS ng-include Directive
AngularJS instance
Include the 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 results:
myFile. htm file title
This text comes from the included file myFile. htm!
Definition and usage
The ng-include directives are used to contain external HTML files.
Contains the content as a child node of the specified element.
The value of the ng-include property can be 1 expression, returning 1 file name.
By default, the included files need to be included under the same domain name.
Grammar
<
element ng-include="filename" onload="expression" autoscroll="expression"
>
<
/element
>
The ng-include instruction is used as an element:
<
ng-include src="filename" onload="expression" autoscroll="expression"
>
<
/ng-include
>
All HTML elements support this instruction.
Parameter value
值 | 描述 |
---|---|
filename | 文件名,可以使用表达式来返回文件名。 |
onload | 可选, 文件载入后执行的表达式。 |
autoscroll | 可选,包含的部分是否在指定视图上可滚动。 |
The above is the knowledge arrangement of AngularJS ng-include instructions, which will be supplemented in the future.