I have a list of dashboards(vm.dashboards) out of which I want to filter the dashboards created by me. By default it displays the entire list but when i click on the "show my dashboard" checkbox , it should display only the list of dashbaords created by me.
HTML code:
<div>
<input type="checkbox" ng-model="showMyDashboard" ng-value="vm.myDashboard" ng-checked="false" ng-true-value="1" ng-false-value="0"><span for="radio" style="margin-left:5px;" class="text-only">Show my dashboards</span>
</div>
<ul ng-repeat="dashboard in vm.dashboards" class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-sm-5"><a class="list-group-item-heading dashboard-heading"> </a>
<p class="list-group-item-text dashboard-text"></p>
</div></li>
</ul>
Now the tricky part is that there is no direct way to get myDashboards list. If(currentUserId === dashboardOwnerId) then that particular dashboard is myDashboard. So I have to apply the condition in the filter. I tried doing this approach:
ul.list-group(ng-repeat="dashboard in vm.dashboards | filter: dashboard.creator["@href"].split("/").pop() === vm.currentUSerID")
So, dashboard.creator["@href"].split("/").pop() will give values like 1, 101, 123. and currentUSerID will give similar values too. When both matches thats when i get the dashboard created by me.
This filter above does totally opposite to what i want and lists all dashboards that are not created by me. Can i give such condition to filters ? do I need to build custom filter for it? Any help/suggestions would be appreciated. Thanks!
Aucun commentaire:
Enregistrer un commentaire