Factory _promise
Promise in factory service
by manoj_antony32
HTML
<div ng-controller="myCtrl">
{{name}}
</div>
JavaScript
var myApp = angular.module('myApp', [])
myApp.factory('myServiceRequest', function($http){
return {
getRequest: function(httpUrl){
return $http.get(httpUrl);
}
}
});
myApp.controller('myCtrl', ['$scope','myServiceRequest','$http', function($scope, myServiceRequest, $http){
$scope.name = "hello";
$scope.ReceivedData = myServiceRequest.getRequest('https://onecsitmappssrvs.cognizant.com/2185/Trutimeapi/TruTimeTopUp/GetMonthTopUpDetails');
console.log($scope.ReceivedData)
$scope.checkService = $http.get('https://onecsitmappssrvs.cognizant.com/2185/Trutimeapi/TruTimeTopUp/GetMonthTopUpDetails');
console.log($scope.checkService)
}]);