Assigning restangular getList results to $scope

angularjs, restangular

Solution

As of angular 1.2, automatic unwrapping of promises was disabled and deprecated. So, while

$scope.projects = Restangular.all('project/').getList();

would have allowed you to access `projects` in your view directly in previous releases (for which the Restangular docs where likely written), that will no longer work automatically. You can reenable the feature via the `$parseProvider.unwrapPromises()` API, but it is deprecated, so your best bet is probably to manually resolve the promise in your controller like in your more verbose example.

See the checkin commit message for more details.

Problem

So it looks like in the examples you can do this: ``` App.controller('ProjectListCtrl', ['$scope', 'Restangular', function($scope, Restangular) { $scope.projects = Restangular.all('project/').getList(); }]); ``` But that doesn't work for me. When I ng-repeat project in projects and look at the scope, I see: ``` { projects: { then: null catch: null finally: null call: null get: null restangularCollection: true push: null } } ``` Which looks like an un resolved promise object right? This works fine but is more verbose: ``` lgtApp.controller('ProjectListCtrl', ['$scope', 'Restangular', function($scope, Restangular) { Restangular.all('project/').getList().then(function(projects){ $scope.projects = projects; }); }]); ``` Did I miss something? This is in the docs: ``` $scope.owners = house.getList('owners') ``` Shouldn't matter, but this happens when I'm testing a phonegap app in the Ripple chrome plugin.

Original source