I'm curious to know the best way to iterate through mongodb with angular to get all domains for a given customer.
Here's my JSON from MongoDB:
{
"_id": {
"$oid": "513568dae4b08eabdba2eb63"
},
"name": "Sofa King",
"contactPrimaryName": "Richard Cranium",
"contactPrimaryPhone": "410 555-1212",
"contactPrimaryEmail": "me@mysite.com",
"PrimaryAddress": "123 Any Street\nApt. 17",
"contactPrimaryCity": "Nashville",
"contactPrimaryState": "TN",
"contactPrimaryZip": "22222",
"site": "http://www.mysite.com", //ignore, replacing with domains
"domains": [
{
"url": "http://www.mysite.com",
"ns1": "ns1.mydns.com",
"ns2": "ns2.mydns.com",
"registered": "2011-01-01",
"expires": "2014-01-01"
},
{
"url": "http://www.myother.com",
"ns1": "ns1.mydns.com",
"ns2": "ns2.mydns.com",
"registered": "2012-02-02",
"expires": "2015-02-02"
}
]
I know that I can get Customer details with the following:
<tr ng-repeat="customer in customers | filter:search | orderBy:'name'">
<td><a href="{{customer.site}}" target="_blank">{{customer.name}}</a></td>
<td>{{customer.contactPrimaryName}}</td>
<td>{{customer.contactPrimaryPhone}}</td>
<td>{{customer.contactPrimaryEmail}}</td>
But I'm not sure how to get domain URLs for a given customer.
My goal is to have a customer list on one page with a button to view the domains for that customer. When viewing the domains for a given customer then having the ability to add a domain.
You should just be able to iterate over the "domains" array for the current customer:
<tr ng-repeat="customer in customers | filter:search | orderBy:'name'">
...
<td>
<div data-ng-repeat="domain in customer.domains">
// Do stuff in here with the domain for that customer
</div>
</td>
</tr>