mirror of
https://github.com/taobataoma/meanTorrent.git
synced 2026-07-07 15:53:01 +02:00
Added Article Delete Support
This commit is contained in:
@@ -15,13 +15,19 @@ angular.module('mean.articles').controller('ArticlesController', ['$scope', '$ro
|
||||
};
|
||||
|
||||
$scope.remove = function(article) {
|
||||
article.$remove();
|
||||
if (article) {
|
||||
article.$remove();
|
||||
|
||||
for (var i in $scope.articles) {
|
||||
if ($scope.articles[i] == article) {
|
||||
$scope.articles.splice(i, 1);
|
||||
for (var i in $scope.articles) {
|
||||
if ($scope.articles[i] == article) {
|
||||
$scope.articles.splice(i, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$scope.article.$remove();
|
||||
$location.path('articles');
|
||||
}
|
||||
};
|
||||
|
||||
$scope.update = function() {
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
<section data-ng-controller="ArticlesController" data-ng-init="findOne()">
|
||||
<span>{{article.created | date:'medium'}}</span> /
|
||||
<span>{{article.user.name}}</span>
|
||||
<h2>{{article.title}} <a data-ng-show="global.user._id == article.user._id" href="/#!/articles/{{article._id}}/edit">edit</a></h2>
|
||||
<div>{{article.content}}</div>
|
||||
</section>
|
||||
<span>{{article.created | date:'medium'}}</span>/
|
||||
<span>{{article.user.name}}</span>
|
||||
<h2>{{article.title}}</h2>
|
||||
<div data-ng-show="global.user._id == article.user._id">
|
||||
<a class="btn" href="/#!/articles/{{article._id}}/edit">
|
||||
<i class="icon-edit"></i>
|
||||
</a>
|
||||
<a class="btn" data-ng-click="remove();">
|
||||
<i class="icon-trash"></i>
|
||||
</a>
|
||||
</div>
|
||||
<div>{{article.content}}</div>
|
||||
</section>
|
||||
|
||||
Reference in New Issue
Block a user