javascript - Setting object data in nested for loop -


i have scope variable called jobs array of objects each department , data.

[ “accounting”: { “foo” : “foo”, “bar” : bar" }, “delivery”: { “foo”: “foo”, “bar”: “bar } ]

the html5 date input requires dates converted using new date() in javascript though in correct yyyy-mm-dd format specified. go through hand , type in each date needs converted, wanted use nested foreach because have lot of dates convert.

angular.foreach($scope.job, function(value, key){     angular.foreach(value, function(innervalue, innerkey){        if(typeof(innervalue) === "string"){          var matches = innervalue.match(/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}/);          if(matches){                // need set $scope.job.key.innerkey = new date($scope.job.key.innerkey) here           }        }      });   }); 

my issues don’t know how access $scope.job object @ key , innerkey values came to. how can edit current item being looped over? documentation on using ‘this’ in situation impossible find.

you need use [] object notation variable property names

if(matches){    value[innerkey] = new date(value[innerkey]); } 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -