Skip to content

Instantly share code, notes, and snippets.

@vaneves
Created September 24, 2015 12:29
Show Gist options
  • Save vaneves/c85764494bac69c3f0e9 to your computer and use it in GitHub Desktop.
Save vaneves/c85764494bac69c3f0e9 to your computer and use it in GitHub Desktop.
Curso Ninja - Controller Post Edit
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