I have an application with Miller Columns, i.e. a series of lists. Each column of this is a view.
The data is pulled in from a json file with a resolve in the route.
The first column displays a table of the top level data, e.g all the accounts in the data:
_this.costAccounts = CostAccountsResolve;
When a user clicks on a row, I load another route into the view for the second column, passing the account number:
$state.go('miller.subaccount', { accountid: item.account_number });
The route is:
.state('miller', {
url: '/miller',
resolve: {
CostAccountsResolve: function (MockDataFactory) {
return MockDataFactory.query({ filename: 'cost_accounts' });
}
},
views: {
....
}
})
.state('miller.subaccount', {
url: '/subaccount/:accountid',
views: {
'subaccounts@miller': {
controller: 'SubaccountController as sub',
templateUrl: 'modules/miller/templates/subaccounts.html'
},
'crud@miller': {}
}
})
So if the user clicks on account number 001 I go to a the subaccount state with id 001: /#/miller/subaccount/001
This should display a table with the subaccounts of account 001. The data is in the format:
[
{
"account_number": "001",
"account_name": "Account 1",
"subaccounts": [
{
"account_number": "00101",
"account_name": "SubAccount 1 of Account 1"
},
{
"account_number": "00102",
"account_name": "SubAccount 2 of Account 1"
}
]
},
{
"account_number": "002",
"account_name": "Account 2",
"subaccounts": [
{
"account_number": "00201",
"account_name": "SubAccount 1 of Account 2"
},
{
"account_number": "00202",
"account_name": "SubAccount 2 of Account 2"
}
]
}
]
This is still stored in the resolve, CostAccountsResolve
. So, how do I populate the table in the subaccounts view with the items in the subaccounts
key for account 001? In other words, I want 00101 and 00102 in the example json above.
CostAccountsResolve
- I don't see any resolve in your state, are you asking about filtering the correct element from the accounts? – Alon Eitan yesterdayaccount_number == "001"
? You can do it with Array.prototype.find() – Alon Eitan yesterday