1
0
mirror of https://github.com/BoostIo/Boostnote synced 2026-02-11 15:01:41 +00:00

refactor update/create behaviors

This commit is contained in:
Rokt33r
2015-06-10 02:36:07 +09:00
parent f1adb9783b
commit 68956ec360
7 changed files with 17 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
/* global angular */
angular.module('codexen')
.controller('SnippetsDetailController', function (Snippet, $state, $rootScope) {
.controller('SnippetsDetailController', function (Snippet, $state, $rootScope, $scope) {
var vm = this
vm.isLoaded = false
@@ -23,4 +23,9 @@ angular.module('codexen')
$rootScope.$broadcast('snippetDeleted')
})
}
$scope.$on('snippetUpdated', function (e, snippet) {
console.log('event received', snippet)
if (snippet.id === vm.snippet.id) vm.snippet = snippet
})
})

View File

@@ -34,7 +34,7 @@ angular.module('codexen')
})
$scope.$on('snippetUpdated', function (e, snippet) {
$state.go('snippets.detail', {id: snippet._id})
$state.go('snippets.detail', {id: snippet.id})
loadSnippets()
})