javascript - AngularJS objects in an array to new one -


this question has answer here:

dashboardservice.getdatelist($scope.datestart, $scope.dateend).then(function (response) {     $scope.listdate = response.data; }); 

i array list function above

[{"day":1,"sql_date":"2017-04-01t00:00:00"}, {"day":2,"sql_date":"2017-04-02t00:00:00"}, {"day":3,"sql_date":"2017-04-03t00:00:00"}, {"day":4,"sql_date":"2017-04-04t00:00:00"}, {"day":5,"sql_date":"2017-04-05t00:00:00"} 

how can push day value array new one.

you can use array#map value of every day key.

var arr = [{"day":1,"sql_date":"2017-04-01t00:00:00"},{"day":2,"sql_date":"2017-04-02t00:00:00"},{"day":3,"sql_date":"2017-04-03t00:00:00"},{"day":4,"sql_date":"2017-04-04t00:00:00"},{"day":5,"sql_date":"2017-04-05t00:00:00"}],      newarr = arr.map(v => v.day);            console.log(newarr);


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -