Http Post and Get Web Api Calls using Angularjs

Http Post and Get Web Api Calls using Angularjs

In this Post We Will Explain About is Http Post and Get Web Api Calls using Angularjs 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 angularjs – how to call API in angular controller Example

In this post we will show you Best way to implement How To Consume WebAPI Using AngularJS, hear for Interacting With RESTful APIs Using $http in AngularJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

What is WEBAPI

API stands for simple Application programming interface.and it’s The main purpose of simple angular webapi is to make restful web-services.

Web API is simple consumed by a large of broad range of some clients like as a

  • 1.IOT (Internet of Things)
  • 2.Mobile Apps
  • 3.Web based Apps and
  • 4.Desktop Apps
app.factory("user_services", ['$http', function($http) {
var LiveServiceBase = 'live24u/api/';
var LiveObj = {};
LiveObj.getStudents = function(){
return $http.get(LiveServiceBase + 'students');
};
LiveObj.getCustomer = function(studentID){
return $http.get(LiveServiceBase + 'student?id=' + studentID);
};
LiveObj.InsertStudent = function (student) {
return $http.post(LiveServiceBase + 'InsertStudent', student).then(function (results) {
return results;
});
};LiveObj.updateStudent = function (id,student) {
return $http.post(LiveServiceBase + 'updateStudent', {id:id, student:student}).then(function (isActive) {
return isActive.data;
});
};
LiveObj.removeStudent = function (id) {
return $http.delete(LiveServiceBase + 'removeStudent?id=' + id).then(function (isActive) {
return isActive.data;
});
};
return LiveObj;
}]);

Angularjs – how to call API in angular controller

varliveApp = angular  
    .module("LiveModule", [])  
    .controller("myCtrl", function($scope, $http) {  
        $http.get('https://www.pakainfo.com/api/home/getstudents').then(function(results) {  
            $scope.students = results.data;  
        });  
    });  

Get Requests : Http Post and Get Web Api Calls using Angularjs

var liveApp = angular.module('liveApp', []);

liveApp.controller('liveACtrl' , function ($scope, $http) {
    $scope.home = "Welcome to Pakainfo.com";
    
    $scope.getStudents = function () {
        console.log("I've been pressed!");  
        $http.get("https://www.pakainfo.com/get?name=jaydeep")
            .then(function successCallback(results){
                $scope.results = results;
            }, function errorCallback(results){
                console.log("Unable to perform get request");
            });
    };
    
});

Post Requests : Http Post and Get Web Api Calls using Angularjs

var liveApp = angular.module('liveApp', []);

liveApp.controller('liveACtrl' , function ($scope, $http) {
    $scope.home = "Welcome to Pakainfo.com";
    
    
// Live24u Example Our GET request function
    $scope.getStudents = function () {
        console.log("I've been pressed Good Luck!");  
        $http.get("https://www.pakainfo.com/get?name=jaydeep")
            .then(function successCallback(results){
                $scope.results = results;
            }, function errorCallback(results){
                console.log("Unable to perform get request");
            });
    };
    
// Live24u Example  Our angularjs POST request function
    $scope.postRequest = function () {
        $http.post("https://www.pakainfo.com/", data)
            .then(function successCallback(results){
                console.log("Good Luck Successfully POST-ed data");
            }, function errorCallback(results){
                console.log("Your most POST-ing of simple data failed");
            });
    };
    
});

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Making API Calls in AngularJS using Angular’s $http service 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.

Leave a Comment