Map Two Collections (inner Join) Using Angularjs Html
I'm having two Collection user and Type. I wish to dispay Email ID which is marked as IsPreffered = TRUE and I need to map the email.Type to Type.ID { 'user' : [ { 'N
Solution 1:
I would suggest doing it in code rather than the markup, but if you need this is one way you can map to Type:
<spanng-repeat="email in collection.user[0].Email| filter: {IsPreffered : true} "ng-if="$last">
Email : {{email.Id}} ,
<spanng-repeat="typename in typeCollection.Type|filter:{ID : email.Type}">
Type: {{typename.Name}}
</span></span>
where typeCollection is :
$scope.typeCollection = {
"Type": [{
"ID": 1,
"Name": "Private"
}, {
"ID": 2,
"Name": "Home"
}, {
"ID": 3,
"Name": "Business"
}, ]
};
Please note that you needed one more ng-repeat in markup because filter works on an array.
EDIT: You can also do this using ng-init:
<spanng-repeat="email in collection.user[0].Email| filter: {IsPreffered : true} "ng-if="$last">
Email : {{email.Id}} ,
<spanng-init="types = (typeCollection.Type|filter:{ID : email.Type})">
Type: {{types[0].Name}}
</span></span>
Solution 2:
for(var i = 0; i < Type.length ; i++)
{
if(user[0].Email.Type to Type[i].ID)
{
user[0].Email.TypeName = Type[i].ID;
}
};
Html
<span ng-repeat="email in collection.user[0].Email | filter: {IsPreffered : true} " ng-if="$last">{{email.TypeName}} : {{email.Id}}</span>
Post a Comment for "Map Two Collections (inner Join) Using Angularjs Html"