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

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

android - ConstraintLayout: Realign baseline constraint in case if dependent view visibility was set to GONE -

c# - Populating Gridview inside Listview ItemTemplate On Web User Control from Code Behind -