3

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"];

2
  • 2
    Object.keys()! Commented Dec 22, 2016 at 12:24
  • Thanks I got it. How can i reform the above object from newly updated "$scope.array = ["aboutyou", "height"]; Commented Dec 22, 2016 at 12:50

2 Answers 2

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

That should do the trick for you.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks I got it. How can i reform the above object from newly updated "$scope.array = ["aboutyou", "height"];
3

This should work:

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

2 Comments

Thanks I got it. I have one more doubt that how can i remove last index value ","
Thanks I got it. How can i reform the above object from newly updated "$scope.array = ["aboutyou", "height"];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.