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.
$scope.projects = Restangular.all('project/').getList().$object;
As an addition to the other comment, even though promise unwrapping was disabled, I implemented in Restangular a new way of having promises unwrap easily for you (Similar to what $resource does what without removing Promises). Check https://github.com/mgonto/restangular#using-values-directly-in-templates for more information :)
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With