Today, in this article, we will learn how to perform CRUD operation with paging, sorting, validation, and also using file upload control, and then, how to retrieve the records from JSON file. Also, we will perform bulk delete operation using checkbox.
So here, I have divided the article into two parts - Part 1 and Part 2
In part1, I will retrieve data and display the records from JSON file with sorting and paging.
In Part2, I will perform Insert, Update, and Delete operations.
So now, we will perform the first part, i.e., reading the data from JSON with sorting and paging.
Step 1
Download the AngularJS library.

Step 2
We will add a JSON file. For that, go to Solution Explorer and right-click to select a new item. Select JSON file, name it and click "Add".

Now, let's write some records related to employee information in JSON format.
Employee.json
- {
- "Employees": [
- {
- "id": 1,
- "firstName": "Mithilesh",
- "lastName": "Mithilesh",
- "address": "Hyderabad",
- "dateOfBirth": "2013-01-08",
- "phoneNo": "8923742593",
- "emailId": "[email protected]",
- "image": "../images/mk253.jpg#",
- "LogoName": "logo-icon.png",
- "selected": false
- },
- {
- "id": 2,
- "firstName": "Sanjeev",
- "lastName": "Kumar",
- "address": "Delhi",
- "dateOfBirth": "2003-01-08",
- "phoneNo": "8923756993",
- "emailId": "[email protected]",
- "image": "../../images/mk253.jpg#",
- "LogoName": "logo-icon.png",
- "selected": false
- },
- {
- "id": 3,
- "firstName": "Neha",
- "lastName": "Kumari",
- "address": "Hyderabad",
- "dateOfBirth": "2013-01-08",
- "phoneNo": "892374293",
- "emailId": "[email protected]",
- "image": "../images/flowers.jpg#",
- "LogoName": "logo-icon.png",
- "selected": false
- },
- {
- "id": 4,
- "firstName": "Sohan",
- "lastName": "Singh",
- "address": "Cuttack",
- "dateOfBirth": "2010-01-08",
- "phoneNo": "892374293",
- "emailId": "[email protected]",
- "image": "../../images/yellow_beautiful_roses-normal.jpg",
- "LogoName": "logo-icon.png",
- "selected": false
- },
- {
- "id": 5,
- "firstName": "Sony",
- "lastName": "Singh",
- "address": "Cuttack",
- "dateOfBirth": "2010-01-08",
- "phoneNo": "892374293",
- "emailId": "[email protected]",
- "image": "../../images/yellow_beautiful_roses-normal.jpg",
- "LogoName": "logo-icon.png",
- "selected": false
- },
- {
- "id": 6,
- "firstName": "Kajal",
- "lastName": "Kumari",
- "address": "Patna",
- "dateOfBirth": "2011-01-08",
- "phoneNo": "892374293",
- "emailId": "[email protected]",
- "image": "../../images/yellow_beautiful_roses-normal.jpg",
- "LogoName": "logo-icon.png",
- "selected": false
- }
- ],
- "selected": {}
- }
Step 3
When we create Angular.js applications, first we add ng-app directive. This is the starting point or root element of any AngularJS application.
So first, we have to create ng-app. For this, add a JavaScript file. Right click on Solution Explorer, go to Add >> New Item and choose a JavaScript File.

Click "Add" button and write the app code using module.
App.js
- var AngularExample = angular.module('AngularExampleApp', ['ui.bootstrap']);
Note
AngularExample: This is the name of the variable of ng-app.
'AngularExampleApp' : This is the name of ng-app of our application.
'ui.bootstrap' : This is the botstrap ui for design and the functionality of paging
Step 4
Now, we will create some services for using in this application. So, add a JavaScript file and write this code.
Service.js
- AngularExample.factory('MyService', function () {
- return {
- EmployeesUri: '/JsonData/Employee.json'
- }
- });
- //$Http Services
- AngularExample.factory('Service',
- ["$http",
- function ($http) {
- return {
- get: function (url) {
- var promise = $http.get(url)
- .success(function (data, status) {
- return data;
- })
- .error(function (data, status) {
- return { "status": false };
- });
- //$scope.isLoading = false;
- return promise;
- }
- }
- }]);
In above js file, we created two services - for reading the JSON data from read Employee.json file and another one is HTTP service.
And also, we have created Config service for paging definition.



GBI CommunityPosted Apr 20, 2021, 2:47 AM
How to run this project?
Neelav KumarPosted Oct 7, 2018, 11:15 PM
HI Mithilesh. Can you describe what changes I need to do to have the employee records fetched from SQL Server instead of a hardcoded Json file? Thank you.
Siddi Khadar ValiPosted Sep 15, 2017, 8:05 AM
Hi Mithilesh, can you please upload the project for downloading. Thanks,Siddi.
Subha Lakshmi Dhal SinghPosted Sep 1, 2017, 12:36 AM
Nice Article Mithilesh :)