Last active
September 24, 2015 11:49
-
-
Save vaneves/05e3e197ef82546a6ceb to your computer and use it in GitHub Desktop.
Curso Ninja - Controller Post List
This file contains 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
'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