First of all, I have some kind of a working solution, but I'm just asking if I can tune it up for better performance. So, I have nested arrays structure looking like this:
$scope.clients = [
{
name: "Ivan Drew",
age: 21,
company: "HP",
apps: [
{
appName: "Facebook",
used: "Y",
installedDate: "21/12/2014"
},
{
appName: "Instagram",
used: "N",
installedDate: "14/12/2014"
}
]
},
{
name: "John Roberts",
age: 35,
apps: [
{
appName: "Messenger",
used: "Y",
installedDate: "01/01/2015"
},
{
appName: "Facebook",
used: "Y",
installedDate: "09/11/2014"
},
{
appName: "Instagram",
used: "Y",
installedDate: "20/10/2014"
}
]
},
{
name: "Richard James",
age: 28,
apps: [
{
appName: "Instagram",
used: "N",
installedDate: "15/11/2014"
}
]
}
];
Now, I want to filter this list to show the clients who have installed e.g. Facebook app and had been using it (used
property shows this). So I want to show the list like this:
Ivan Drew
Facebook
21/12/2014
John Roberts
Facebook
09/11/2014
I created my html with two ng-repeat
to look like this:
<div class="client-info" ng-repeat="client in clients">
<div ng-repeat="app in client.apps | filter: { name: 'Facebook', used: 'Y' }">
{{ client.name }}<br />
{{ app.appName }}<br />
{{ app.installedDate }}<br />
</div>
</div>
So, as I said above, this works as expected, but I checked it when you have a lot of information (e.g. 1000 clients with 5 apps at least for each one) it get laggy a lot. So I checked what is the output for this and saw that .client-info
elements are shown (empty of course), even though none of the apps match the requirements.
I was thinking about how to optimize it, but came up short for now.
Anybody has some ideas how to make it better?
Thanks in advance! :)
Angular
entirely withReact.js