From the Angular docs:
The action methods on the class object or instance object can be invoked with the following parameters:
HTTP GET "class" actions: Resource.action([parameters], [success], [error])
non-GET "class" actions: Resource.action([parameters], postData, [success], [error])
non-GET instance actions: instance.$action([parameters], [success], [error])
Success callback is called with (value, responseHeaders) arguments. Error callback is called with (httpResponse) argument.
So you would have to do:
$scope.user.$save({}, function(data,headers) {
//success
$location.path('/');
}, function(response) {
//error
alert("error")
});
Or
$scope.user.$save({}, {}, function(data,headers) {
//success
$location.path('/');
}, function(response) {
//error
alert("error")
});
I'm not sure which is classified as a "class action" - I assume user is an instance but I'm not positive.
If you want to update the info in the sidebar, you could broadcast that the post has finished:
$rootScope.$broadcast('user:saved')
and do whatever logic you need to in the sidebar
//in your sidebar controller or wherever
$scope.$on('user:saved', function() {
});