I am new to AngularJS trying to create my own Custom Service. I am using $http method. Here is my code
HTML:
<div ng-app="dummyApp">
<div ng-controller="myserctrl">
<label>My label</label>
{{resData}}
</div>
Ctrl:
var myreq = angular.module("dummyApp", []);
myreq.controller('myserctrl', function($scope, myService, $rootScope) {
$scope.resData = result.data.content;
});
Service:
myreq.service("myService", function($rootScope, $http){
$rootScope.result = {};
$http.get('https://api.myjson.com/bins/dtm5r')
.then(function (data) {
result = data;
console.log($rootScope.result);
})
.then(function (data){
console.log("the Data is error")
})
});
My call was going and I am getting the successful result but I am missing something in the control, because I am not getting the proper data in the html.