0

So I have a web server that is handling my .json files.

On the client side a have a simple service :

var service = angular.module('services.service', ['ngResource']);

service.factory('Service', ['$resource',

    function($resource){
        return $resource('json/:serviceId.json', {},
            {

            }
        );

    }
]);

but when I call it from the controller :

$scope.service = Service.get({serviceId : id} );

I don't get anything written into the $scope.service

I've checked my network, and the .json file arrives, but is not handled?

Don't know what to do

2
  • 1
    Is the JSON malformed? can you post it here? Also you can try to catch errors Service.get({serviceId: id}).$promise.then(console.log,console.log); Commented Sep 3, 2014 at 18:12
  • 1
    Thnx man, you saved me, it was malformed. Lost an hour on this sh*t. Post a answer, I'll accept it. Commented Sep 3, 2014 at 18:16

2 Answers 2

1

The JSON could be malformed. You can look at the response from the call in more detail by logging it:

Service.get({serviceId: id}).$promise['finally'](console.log);
Sign up to request clarification or add additional context in comments.

Comments

0

use this in controller.

 Service.get({serviceId : id} ).$promise.then(function(d){
    $scope.service = d;
    })
    .catch(function(err){
    console.log(err);
    })

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.