Kaynağa Gözat

Add delete all button

Lily Carpenter 10 yıl önce
ebeveyn
işleme
cfbeafffc8
3 değiştirilmiş dosya ile 9 ekleme ve 1 silme
  1. 1 1
      www/css/app.css
  2. 3 0
      www/index.html
  3. 5 0
      www/js/controllers/noteCtrl.js

+ 1 - 1
www/css/app.css

@@ -11,7 +11,7 @@
11 11
   width: 300px;
12 12
 }
13 13
 
14
-h1 {
14
+h1, .delete_all {
15 15
   text-align: center;
16 16
 }
17 17
 

+ 3 - 0
www/index.html

@@ -6,6 +6,9 @@
6 6
   <body>
7 7
     <div ng-controller="NoteCtrl">
8 8
       <h1>Notes</h1>
9
+      <div class="delete_all">
10
+        <input type="submit" value="Delete all" ng-click="deleteAllNotes()" />
11
+      </div>
9 12
       <div class="new_note_form">
10 13
         <h2>New note</h2>
11 14
         <p><input ng-model="newNote.title" /></p>

+ 5 - 0
www/js/controllers/noteCtrl.js

@@ -20,4 +20,9 @@ angular.module('bootcampApp')
20 20
       $scope.notes.splice($scope.notes.indexOf(note), 1);
21 21
       Notes.saveData($scope.notes);
22 22
     };
23
+
24
+    $scope.deleteAllNotes = function(){
25
+      $scope.notes = [];
26
+      Notes.saveData($scope.notes);
27
+    };
23 28
   });