Services in Angular JS

0
 Services in Angular JS :-

It is used to add external functionality ,features in angular js application from Remote Web Server.

Service always will be defined as a method in angular JS Controller.


Service use to provide business code as well as Http data from web server.


To access Http data angular provide $http variable which will be defined under controller section.


Complete Code to get registration web service data in angular js application.

CORS should be enabled in angular JS Web services then it will be displayed .

..................................................................................................

<!DOCTYPE html>

<html>

<head>

<title>

AngularJs $http.get() Service Response Example

</title>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>


</head>

<body>

<div ng-app="serviceApp" ng-controller="serviceCtrl">



<h1>{{myWelcome}}</h1>



</div>
<script type="text/javascript">

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

app.controller('serviceCtrl', function ($scope, $http) {

$http({

method: 'GET',

url: 'http://shivaconceptsolution.com/webservices/showreg.php'

}).then(function success(response) {

$scope.myWelcome = response.data;



}, function error(response) {

});

});

</script>

</body>

</html>





Tags

Post a Comment

0Comments

POST Answer of Questions and ASK to Doubt

Post a Comment (0)