Skip to main content

Posts

Showing posts with the label Is $http service is restful web service in angularjs

How to call Restful APIs/Services in AngularJs?

In the AngularJs, we can use following methods to achieve this. 1.       $http Service 2.       $resource Service 3.       Rest Angular The example as, < ! DOCTYPE html > < html > < head > < script src = "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js" > < /script > < script src = "https://code.angularjs.org/1.5.8/angular.js" > < /script > < script > var appController = function ($scope, $http) { $ http.get( "http://jsonip.com" ) .success( function (response) { $ scope.Info = response; }) .error ( function (response) { $ scope.message = "Error!!" ; }); } < /script > < /head > < body > < div ng - app ng - controller = "appController" > < h3 > How to call Restful APIs/Services in AngularJs? < /h3 > < div ...

Is $http service is restful web service in angularjs?

What is $http service in angularjs? The $http service is a service that provide the communication between the remote HTTP servers using the browser's XMLHttpRequest object or JSONP . The $http is normal Ajax  form and it can be used for any form of Web Service. Specifically for RESTful  service, we are using $resource .  The $resource Is useful to consume RESTful Service and $resource is high level abstraction of $http. The $resource is developed on the top of $http service. For example for RESTful service var app = angular.module( "myApp" , [ 'ngResource' ]); app.controller( "RESTfullCtrl" , [ '$scope' , '$resource' , function ($scope, $resource) {     $scope.employees = [];     var emp = $resource( '/employee/:employeeId' , { employeeId: '@employeeId' });     // GET Action Method     emp.get({ employeeId: 0112 }, function (data) {    ...