0
.factory('MY', function($http){
return {
    mustafa: function(){
        var factory = {};
        var url = '/uzak/remote.php?callback=JSON_CALLBACK';
        var yarro = $http.get(url).success(function(response){
        return response.data);
        });
        return yarro;
    }
}
})
.controller('nbgCtrl', function() {
$scope.mangas = MY.mustafa();
 })

I wanna use json data above like. But it isn't working. Could you guys help me?

1
  • Hey Nasuh, do you think you could unselect my response as the answer? I would like to delete my response. Commented Nov 15, 2017 at 22:27

1 Answer 1

2

You can return the promise, and then resolve it in the controller:

.factory('MY', function($http){
  return {
    mustafa: function() {
        var url = '/uzak/remote.php?callback=JSON_CALLBACK';
        return $http.get(url);
    }
  };
})

Finally, you have to inject the service to the controller.

.controller('nbgCtrl', function($scope, MY) {
  MY.mustafa().success(function(response) {
    $scope.mangas = response.data;
  );
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.