Overview
In this article, we will see how to use ngInclude directive in AngularJS, with an example. Also, we will learn what ngInclude directive is and what is its purpose.
For more articles on AngularJS, kindly refer to.
- Overview Of AngularJS
- Modules And Controller In AngularJS
- Controllers in AngularJS
- AngularJS ng src Directive
- AngularJS ng-Repeat Directive
- Handling Events In AngularJS
- How To Use Two-Way Data Binding In AngularJS
- Filters In AngularJS
Introduction
- ngInclude directive is used to embed an HTML Page into another HTML Page.
- This is used when you want to reuse the specific Page/View in multiple views, in your application.
The Value for ngInclude directive can be the name of the page that we want to include or a property on the $Scope object that points to the reusable feature of a page.
We will see this with an example. We have a controller function. In that controller function, we have an employee array.
var mypartone = angular.module("mymodule", []).controller("myController", function($scope) {
var employees = [
{
name: "Akshay",
gender: 1,
dateOfBirth: new Date("July 21, 1960"),
Address: "Mumbai",
Salary: "1234.34"
},
{
name: "Milind",
gender: 2,
dateOfBirth: new Date("July 20, 1960"),
Address: "Nashik",
Salary: "12.34"
},
{
name: "Raghvan",
gender: 1,
dateOfBirth: new Date("July 19, 1960"),
Address: "Pune",
Salary: "1235.34"
},
{
name: "Hari",
gender: 1,
dateOfBirth: new Date("July 18, 1960"),
Address: "Mumbai",
Salary: "5589.34"
}
];
$scope.employees = employees;
});
Now, we will add a page and represent the data on this.
Go to solution; Add new Item ->Web form; name it as Angular1.aspx.

Angular1.aspx

So, in that Angular1.aspx, we are going to use a table element in which <th> section will be used to display various headers and <thead> section. We are going to bind it with a binding expression as shown in the below code.





Ravi KandelPosted Aug 1, 2016, 7:03 AM
Great
Vignesh ManiPosted Jul 30, 2016, 8:19 PM
Nice
Muhammad Aqib ShehzadPosted Jul 30, 2016, 11:25 AM
Nice tutorial
Prasanna MuraliPosted Jul 30, 2016, 10:45 AM
Nice one..
Debasis SahaPosted Jul 30, 2016, 2:14 AM
Good one..