0

I have this data:

 $scope.data = [
        {
            data1:"1",
            data2:"2"

        },
        {
            data1:"1",
            data2:"2"
        }
      ];

I want to output them in console log as:

[ [1,2], [1,2] ]

Any suggestions please.

2 Answers 2

1
$scope.data = [{
    data1:"1",
    data2:"2"
}, {
    data1:"1",
    data2:"2"
}].map(function (o) {
    return [o.data1, o.data2];

    // or, if you really need the items to be numbers:

    // return [o.data1, o.data2].map(Number);
});
Sign up to request clarification or add additional context in comments.

Comments

0

Yao,

Look at Lodash or ngLodash. Lodash has lots of function that do exactly what you are looking to do. ngLodash is a fork and AngularJS rewrite of Lodash.

https://github.com/rockabox/ng-lodash

https://lodash.com

Hope this helps!

Regards, Jeff

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.