123456789101112131415161718192021222324 |
- app.directive('selectedMeals',['$interval',function($interval){
- return {
- replace: true,
- resctrict: 'E',
- templateUrl: 'app/views/selected-meals.html',
- scope: {
- meals: '=',
- },
- controller: function($scope){
- $interval(function(){
- if(firebase.auth().currentUser){
- $scope.ref = firebase.database().ref().child('users').child(firebase.auth().currentUser.uid).child('meals');
- }
- },1000)
- $scope.unselect = function(i){
- if(firebase.auth().currentUser){
- var keys = Object.keys($scope.meals);
- $scope.meals[keys[i]].isSelected = false;
- $scope.ref.child(keys[i]).set($scope.meals[keys[i]]);
- }
- }
- }
- }
- }])
|