I have action links on a page that change parts of the model. The links have ng-click functions that fire a server action that returns the part of the model that was altered. I assign the result of $http.get(...) to the part of the model that was changed. But the data is never resolved.
GuideControllers.controller('VideoDetailCtrl', ['$scope', '$http', '$routeParams', 'Video',
function($scope, $http, $routeParams, Video, Preference) {
$scope.video = Video.get({ id: $routeParams.id });
$scope.addToWatchlist = function(id) {
$scope.video.prefs = $http.get('/api/preference/'+id+'/add_to_watchlist.json')
}
}
]);
The first Video.get(...) fills in the model with a promise that eventually changes the page, the video.prefs are correct when resolved. But when I fetch the video.prefs individually they never get resolved. I tried saving the $http.get promise in a separate variable then on $http.get(...).success(... I copied the parts out the the variable to videos.prefs but that didn't work either since the temp viable was a promise--I guess.
How should I change part of the model by asking the server for just that bit?
.successafter the.get, or else it wont resolve, unless you're doing that later.$scope.video.prefs? Is it a HTML bind?