1

I have the following object.

$scope.sampleObj = 
  {
    "id": 10000,
    "transactionid": "gec43434",
    "status": "COMPLETED",
    "session_id": "TTYUU455667"
  }

Now I need to show this object key in Label and value in text area using ng-repeat. Essentially I want to use ng-repeat on object properties, is it possible?

I have to use something like :

<div ng-repeat="eachProp in sampleObj">
<label> {{eachProp.key}} </label> <textarea ng-model="eachProp.value"> </textarea>
</div> 
Madasu K
  • 1,813
  • 2
  • 38
  • 72

1 Answers1

1

Yes, you can iterate over an object via ng-repeat. you are trying to get this :

<div ng-repeat="(key,value) in sampleObj">
     <label> {{key}} </label> 
     <textarea ng-model="value"></textarea>
</div>

Refer documentation https://docs.angularjs.org/api/ng/directive/ngRepeat

JSfiddle link : https://jsfiddle.net/U3pVM/28214/

Sourav Mondal
  • 405
  • 2
  • 12