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:
@@ -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
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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()
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user