Skip to content

Instantly share code, notes, and snippets.

@vaneves
Created September 24, 2015 11:49
Show Gist options
  • Save vaneves/9f9e237f1cd280b1b667 to your computer and use it in GitHub Desktop.
Save vaneves/9f9e237f1cd280b1b667 to your computer and use it in GitHub Desktop.
Curso Ninja - Controller Post Creat
controllers.controller('PostCreateCtrl', function ($scope, $location, PostService, toastr) {
$scope.save = function () {
PostService.save($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