mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-24 07:01:48 +00:00
bind delete button
This commit is contained in:
@@ -22,9 +22,16 @@ angular.module('codexen.services')
|
||||
return $http.get(url)
|
||||
}
|
||||
|
||||
var destroy = function (id) {
|
||||
var url = apiUrl + 'snippets/id/' + id
|
||||
|
||||
return $http.delete(url)
|
||||
}
|
||||
|
||||
return {
|
||||
findByUser: findByUser,
|
||||
create: create,
|
||||
show: show
|
||||
show: show,
|
||||
delete: destroy
|
||||
}
|
||||
})
|
||||
|
||||
@@ -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')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<span class="detail-header-control pull-right">
|
||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-share"></i></button>
|
||||
<button type="button" name="button" class="btn btn-default"><i class="fa fa-edit"></i></button>
|
||||
<button type="button" name="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
|
||||
<button ng-click="vm.delete()" type="button" name="button" class="btn btn-danger"><i class="fa fa-trash"></i></button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
</div>
|
||||
|
||||
<div ng-if="vm.isLoaded" class="">
|
||||
<p class="tags">
|
||||
<p class="tags" ng-if="vm.snippet.tags">
|
||||
<small><i class="fa fa-tags"></i></small> <a ng-repeat="tag in vm.snippet.tags" ng-bind="tag.name" href="#" class="label label-default"></a>
|
||||
</p>
|
||||
<label>Description</label>
|
||||
|
||||
@@ -37,4 +37,8 @@ angular.module('codexen.states')
|
||||
laodSnippets()
|
||||
})
|
||||
|
||||
$scope.$on('snippetDeleted', function () {
|
||||
laodSnippets()
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<p ng-bind="snippet.description"></p>
|
||||
<p class="tags">
|
||||
<p class="tags" ng-if="snippet.tags.length">
|
||||
<small><i class="fa fa-tags"></i></small> <a ng-repeat="tag in snippet.tags" ng-bind="tag.name" href="#" class="label label-default"></a>
|
||||
</p>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user