CRUD operation using AngularJS and WebAPI in ASP.NET WebForm
In this Post We Will Explain About is CRUD operation using AngularJS and WebAPI in ASP.NET WebForm With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to crud operation in angularjs with web api Example
In this post we will show you Best way to implement crud operations in mvc 5 using web api with angularjs, hear for CRUD operation using AngularJS and WebAPI in ASP.NET WebForm with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.
Make Team ASP.NET WebAPI
Define CustomerApp and Factory
var app = angular.module('teamApp', []); var url = 'api/teams/'; app.factory('teamFactory', function ($http) { return { getTeam: function () { return $http.get(url); }, addTeam: function (team) { return $http.post(url, team); }, deleteTeam: function (team) { return $http.delete(url + team.teamID); }, updateTeam: function (team) { return $http.put(url + team.Id, team); } }; });
TeamController
app.controller('TeamController', function PostsController($scope, teamFactory) { $scope.indianTeams = []; $scope.progressing = true; $scope.addnwmode = false; $scope.toggleTeam = function () { this.team.editTeam = !this.team.editTeam; }; $scope.toggleAddTeam = function () { $scope.addnwmode = !$scope.addnwmode; }; $scope.save = function () { $scope.progressing = true; var tm = this.team; teamFactory.updateTeam(tm).success(function (data) { alert("Team Saved Successfully!!"); tm.editTeam = false; $scope.progressing = false; }).error(function (data) { $scope.error = "An some Error has occured while Saving team! " + data.ExceptionMessage; $scope.progressing = false; }); }; // add Team $scope.add = function () { $scope.progressing = true; teamFactory.addTeam(this.newteam).success(function (data) { alert("Added Successfully!!"); $scope.addnwmode = false; $scope.indianTeams.push(data); $scope.progressing = false; }).error(function (data) { $scope.error = "An Error has occured while Adding team! " + data.ExceptionMessage; $scope.progressing = false; }); }; // delete Team $scope.delTeam = function () { $scope.progressing = true; var currentTeam = this.team; teamFactory.deleteTeam(currentTeam).success(function (data) { alert("Deleted Successfully!!"); $.each($scope.indianTeams, function (i) { if ($scope.indianTeams[i].teamID === currentTeam.teamID) { $scope.indianTeams.splice(i, 1); return false; } }); $scope.progressing = false; }).error(function (data) { $scope.error = "An Error has occured while Saving team! " + data.ExceptionMessage; $scope.progressing = false; }); }; //get all teams teamFactory.getTeam().success(function (data) { $scope.indianTeams = data; $scope.progressing = false; }) .error(function (data) { $scope.error = "An Error has occured while progressing posts! " + data.ExceptionMessage; $scope.progressing = false; }); });
Full Page Code:(index.html)
Team App | Pakainfo.com /1.0.6/angular.min.js jquery/1.8.2/jquery.min.js css/bootstrap.css #liveDiv { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1000; background-color: #c30000; opacity: .8; } .ajax-loader { position: absolute; left: 48%; top: 48%; margin-left: -25px; /* -1 * image width / 2 */ margin-top: -25px; /* -1 * image height / 2 */ display: block; }
You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example
I hope you have Got What is ASP.NET Web API application with Angularjs Forms and Bootstrap And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.