AngularJSng-includeディレクティブ


外部ファイルからHTMLを含める:

<div ng-include="'myFile.htm'"></div>

定義と使用法

ng-includeディレクティブには、外部ファイルからのHTMLが含まれます

含まれるコンテンツは、指定された要素の子ノードとして含まれます。

属性の値はng-include、ファイル名を返す式にすることもできます。

デフォルトでは、インクルードされたファイルはドキュメントと同じドメインに配置されている必要があります。


構文

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

ng-includeディレクティブは、要素としても使用できます。

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

すべてのHTML要素でサポートされています。


パラメータ値

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.