1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-20 13:11:44 +00:00

bind delete button

This commit is contained in:
Rokt33r
2015-05-29 18:58:46 +09:00
parent e5b265e497
commit 7c9d276a1f
6 changed files with 27 additions and 140 deletions

View File

@@ -1,6 +1,6 @@
/* global angular */
angular.module('codexen.states')
.controller('SnippetsDetailController', function (Snippet, $state) {
.controller('SnippetsDetailController', function (Snippet, $state, $rootScope) {
var vm = this
vm.isLoaded = false
@@ -8,8 +8,16 @@ angular.module('codexen.states')
var snippetId = $state.params.id
Snippet.show(snippetId)
.success(function (data) {
vm.snippet = data.snippet
vm.isLoaded = true
.success(function (data) {
vm.snippet = data.snippet
vm.isLoaded = true
})
vm.delete = function () {
Snippet.delete(vm.snippet._id)
.success(function () {
$rootScope.$broadcast('snippetDeleted')
$state.go('snippets')
})
}
})