Andrii 6 年 前
コミット
2158feeb12

+ 25 - 0
app/controllers/SelectMenuPageController.js

@@ -11,6 +11,7 @@ app.controller('SelectMenuPageController',['$scope','$firebaseObject','$timeout'
     var keys = Object.keys($scope.meals);
     $scope.meals[keys[i]].isSelected = true;
     ref.child(keys[i]).set($scope.meals[keys[i]]);
+    //console.log($scope.meals[keys[i]])
   }
   ref.on('value', snap => {
     // var databaseT0ests = [];
@@ -39,4 +40,28 @@ app.controller('SelectMenuPageController',['$scope','$firebaseObject','$timeout'
     })
   }
 
+  // Andrii code start
+
+  $scope.deleteMeal = function(i){
+    var keys = Object.keys($scope.meals);
+    $scope.meals[keys[i]].isSelected = false;
+    ref.child(keys[i]).set($scope.meals[keys[i]]);
+  }
+
+
+  /*
+    // Нужно написать функцию которая будет обнолять все isSelected на false при запуске приложения
+    
+    $scope.reloadItems = function(){
+      var keys = Object.keys($scope.meals);
+      for(var i =0; i<$scope.meals.length; i++) {
+        $scope.meals[keys[i]].isSelected = false;
+        ref.child(keys[i]).set($scope.meals[keys[i]]);
+      }
+    }
+
+  */
+
+// Andrii code end
+
 }])

+ 3 - 0
app/views/select-menu-page.html

@@ -37,6 +37,9 @@
           <li ng-repeat="ingredient in meal.ingredients">- {{ingredient}}</li>
         </ul>
       </div>
+      <!-- цена -->
+      <!-- кнопка добавить -->
+      <!-- отметка добавленно -->
     </div>
   </div>
 </div>

+ 28 - 2
app/views/selected-meals.html

@@ -1,3 +1,29 @@
-<div class="selected-meals">
-  <h1>hi</h1>
+<div class="selected-meals" ng-controller="SelectMenuPageController">
+  <h2>Breakfast</h2>
+  <div  ng-repeat="meal in meals">
+      <p ng-if="meal.type == 'breakfast' && meal.isSelected == true">{{meal.mealName}} | {{meal.isSelected}}
+        <button type="button" name="button" ng-click="deleteMeal($index)">Delete</button>
+      </p>
+  </div>
+  <hr>
+  <h2>Lunch</h2>
+  <div  ng-repeat="meal in meals">
+      <p ng-if="meal.type == 'lunch' && meal.isSelected == true">{{meal.mealName}} | {{meal.isSelected}}
+        <button type="button" name="button" ng-click="deleteMeal($index)">Delete</button>
+      </p>
+  </div>
+  <hr>
+  <h2>Dinner</h2>
+  <div  ng-repeat="meal in meals">
+      <p ng-if="meal.type == 'dinner' && meal.isSelected == true">{{meal.mealName}} | {{meal.isSelected}}
+        <button type="button" name="button" ng-click="deleteMeal($index)">Delete</button>
+      </p>
+  </div>
+  <hr>
+  <h2>Snacks</h2>
+  <div  ng-repeat="meal in meals">
+      <p ng-if="meal.type == 'snacks' && meal.isSelected == true">{{meal.mealName}} | {{meal.isSelected}}
+        <button type="button" name="button" ng-click="deleteMeal($index)">Delete</button>
+      </p>
+  </div>
 </div>