Skip to content

Instantly share code, notes, and snippets.

@vaneves
Last active September 24, 2015 11:49
Show Gist options
  • Save vaneves/05e3e197ef82546a6ceb to your computer and use it in GitHub Desktop.
Save vaneves/05e3e197ef82546a6ceb to your computer and use it in GitHub Desktop.
Curso Ninja - Controller Post List
'use strict';
var controllers = angular.module('ninja.controllers', []);
controllers.controller('PostListCtrl', function ($scope, PostService, toastr) {
$scope.posts = PostService.query();
$scope.delete = function (id) {
PostService.delete({id: id})
.$promise
.then(function () {
toastr.success('Post exlcuído com sucesso');
$scope.posts = PostService.query();
}, function () {
toastr.error('Ocorreu um erro ao tentar excluir o post');
});
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment