Framework: AngularJS 1.4.X
Problem: Accessing Object with in Object
In Built directive: ng-repeat
In Directive:
for ( i=0; i< something.lenght < i++)
if ( element in elements ){
sendData[i]=
{
pair:element,
row:i
}
}
}
scope.obj[sendData] = sendData;
In View:
<somedirective obj="obj">
<md-content ng-repeat="data in obj">
{{obj[data].pair}} or {{data.pair}}
</md-content>
</somedirective>
Console Log ( JSON.stringify(scope.obj)
):
{"[object Object]":{"14":{"pair":"HIT|CEDR3","row":14},"15":{"pair":"HIT|CEPR3","row":15},"16":{"pair":"HIT|CEKR3","row":16},"24":{"pair":"Book|Pro0","row":24}}
{{data}}:
{"14":{"pair":"HIT|CEDR3","row":14},"15":{"pair":"HIT|CEPR3","row":15},"16":{"pair":"HIT|CEKR3","row":16},"24":{"pair":"Book|Pro0","row":24}}
I'm not able to access pair
property from the second object in ng-repeat, as i mentioned in the view section i have used {{obj[data].pair}} or {{data.pair}}
and if i use {{data}}
it will print all object property/data list.
scope.obj = {};
for ( i=0; i< something.lenght < i++)
if ( element in elements ){
sendData[i]=
{
pair:element,
row:i
}
}
}
scope.obj = sendData;
I hope this will help others, and thank you Oskar.