Created
September 24, 2015 12:29
-
-
Save vaneves/c85764494bac69c3f0e9 to your computer and use it in GitHub Desktop.
Curso Ninja - Controller Post Edit
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
controllers.controller('PostEditCtrl', function ($scope, $routeParams, $location, PostService, toastr) { | |
$scope.post = PostService.get({id: $routeParams.id}); | |
$scope.save = function () { | |
PostService.update({id: $routeParams.id}, $scope.post) | |
.$promise | |
.then(function () { | |
toastr.success('Post salvo com sucesso'); | |
$location.path('#/list'); | |
}, function () { | |
toastr.error('Ocorreu um erro ao tentar salvar o post'); | |
}); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment