Note that there are some explanatory texts on larger screens.

plurals
  1. POswitching from $resource to Restangular
    primarykey
    data
    text
    <p>i read good things about restangular, but i don't know how to switch from my current config which is using $resource. </p> <p><strong>here is my actual setup working with $resource :</strong> </p> <p>inside the service.js: </p> <pre><code>.factory('List', function($resource) { return $resource('relative/url/to/json/:type/:id', { type:'@type', id:'@id' }); }) </code></pre> <p>two different controllers use this service :</p> <p>• the "detail" controller</p> <pre><code>.controller('DetailCtrl', ['$scope', '$routeParams', 'List', function($scope, $routeParams, List) { var p = {'type': $routeParams.type, "id": $routeParams.id }; List.get(p, function(detail, responseHeaders) { // success callback $scope.detail = detail; // do something with responseHeaders }); }]) </code></pre> <p>• the "list" controller: </p> <pre><code>.controller('ListCtrl', ['$scope', 'List', function($scope, List) { var params = { sort: 'DESC', limit: 8 }; $scope.loadList = function (type, params) { params.type = type; List.query(params, function(list, responseHeaders) { // success callback $scope.list = list; // do something with responseHeaders }); } }]) </code></pre> <p><strong>i want to replace all the $resource stuff with restangular.</strong> </p> <p>after configuration, Restangular is fetching the datas in a basic way, like this : </p> <p>• inside the "detail" controller</p> <pre><code>$scope.elm = Restangular.one($routeParams.type, $routeParams.id).get(); </code></pre> <p>• inside the "list" controller</p> <pre><code>var params = { sort: 'DESC', limit: 8}; $scope.loadList = function (type, params) { $scope.list = Restangular.all(type).getList(params); } </code></pre> <p>this is working. but now : </p> <p><strong>1. how is it possible to get the response headers ?</strong></p> <p><strong>2. how is it possible to send the datas to the scope inside a success callback function ?</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload