AngularJS ng-include Directive
AngularJS has a built-in directive to include the functionality from other AngularJS files by using the ng-include directive. The primary purpose of the ng-include directive is used to fetch, compile, and include an external HTML file in the main AngularJS application. These are added as child nodes in the main application. The ng-include attribute’s value can also be an expression, that returns a filename. It is supported by all HTML elements.
<element ng-include="filename" onload="expression" autoscroll="expression" > Content... </element>
Note: Here the onload and autoscroll parameter are optional, onload define an expression to evaluate when the included file is loaded and autoscroll define whether or not the included section should be able to scroll into a specific view.
Example 1: This example describes the AngularJS ng-include Directive by fetching the data from the child.html file.
External HTML file: Save this file as child.html.
Example 2: This example describes the AngularJS ng-include Directive by fetching the data in the tabular format from the table.html file.
External HTML file: Save this file as table.html.