kalai
kalai

Reputation: 187

How to get key from key value object in Angularjs?

I need to get key from the key value object inside array.

$scope.rolehiddenfields = [{"aboutyou": "aboutyou", "height": "height"}];

But want as $scope.allrolehiddenfields = ["aboutyou", "height"];

Upvotes: 3

Views: 3690

Answers (2)

Bhuneshwer
Bhuneshwer

Reputation: 587

This should work:

Object.keys({ "aboutyou": "aboutyou", "height": "height" })

Upvotes: 3

rrd
rrd

Reputation: 5957

Object.keys($scope.rolehiddenfields[0]);

That should do the trick for you.

Upvotes: 4

Related Questions