mardi 21 juin 2016

AngularJS and JSON object

I have been stuck on this issue for some time now. I would appreciate your help. I've attached a plunker. http://ift.tt/28NDc42

(function () {
'use strict';

angular
    .module('scheduling')
    .controller('ScheduleCtrl', ['$scope', '$rootScope', '$log', '$filter',  function ($scope, $rootScope, $log, $filter) {



        $scope.selectedDay = function () {
            $rootScope.day = Object.keys($scope.day).map(key => $scope.day[key]);
            $rootScope.day = $scope.day;
            $rootScope.schedule.weekdays.day['@'].day = $rootScope.day;
            console.log($rootScope.day);           

        }                   



    }]);

})();

Objective: I need to be able to select a day or multiple days and have that value get saved to $rootScope.day in the $rootScope.schedule object. The value needs to get save as day:0, day:1, day:2 etc. My initial problem is that the value was getting stored as sun:0, mon:1, tue:2 etc. I was able to find a way to remove the day names (sun, mon, tue) but now it is storing the value as 0:0, 1:1, 2:2 etc.

Can you please view the full code on Plunker, and let me know how I can achieve having day in front of the number value (day:1 or day:1,2,3) ?

NOTE: I have tried using checklist-model and ngRepeat methodolgy but that is not working either.

Thanks for your help.




Aucun commentaire:

Enregistrer un commentaire