Selaa lähdekoodia

delete articles

David 10 vuotta sitten
vanhempi
commit
822ab286b7
2 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 1 1
      front/index.html
  2. 9 0
      front/js/app.js

+ 1 - 1
front/index.html

@@ -64,7 +64,7 @@
 				<section ng-repeat="n in news" ng-class-odd="'odd-news'" ng-class-even="'even-news'">
 					<div class="title">
 						<h4>{{n.title}}</h4>
-						<a href="#"><i class="fa fa-times"></i></a>
+						<a href="#" ng-click="delete_article(n._id)"><i class="fa fa-times"></i></a>
 					</div>
 					<ul class="news-meta">
 						<li><i class="fa fa-calendar-o"></i> {{n.scrap_date | date:'short'}}</li>

+ 9 - 0
front/js/app.js

@@ -81,4 +81,13 @@ app.controller('main', function($scope,$http,$sce) {
 		$scope.curPage=newPage; //clamp
 		$scope.filter(newPage);
 	};
+	$scope.delete_article = function(id) {
+		$http.get("/pymnts/article/delete/"+id).then(
+			function(data) {
+				$scope.news=$scope.news.filter(function(el) { return !(el._id == id) } );
+			},
+			function(data){
+			}
+		);
+	};
 });