In the code below. When i put the return true
in the .error
or in the .success
function. Then nothing happends.
But when I put it outside my .error
or .success
function then it returns nicely and it closes my ngDialog
when i return true
. However I don't really understand why.
angular.module('App')
.controller('NewUserController',function($scope, User, $http){
$scope.user = {};
$scope.save = function()
{
User.create($scope.user)
.success(function(data){
console.log('success');
return true;
})
.error(function(data){
console.log('error')
return false;
});
return true;
}
});