Ho due oggetti JSON definiti in un controller (NotificationsController
). Uno con tutte le notifiche e un altro con solo l'ID delle ultime notifiche (ultimi 3 giorni).Ricerca tramite oggetto JSON con classe ng (AngularJS)
Formato dell'oggetto "notifiche": (t_notifications
)
[{"0":"1","1":"4","2":"14-APR-16","3":"ALERT 1","ID":"1","ID_USER":"4","DATE":"14-APR-16","NOTIFICATION":"ALERT 1!"},{"0":"2","1":"1","2":"07-APR-16","3":"ALERT 2!","ID":"2","ID_USER":"1","DATE":"07-APR-16","NOTIFICATION":"ALERT 2!"},{"0":"3","1":"1","2":"13-APR-16","3":"ALERT 3!","ID":"3","ID_USER":"1","DATE":"13-APR-16","NOTIFICATION":"ALERT 3!"}]
Formato di oggetto "notifiche più recenti": (newest_notifications
)
[{"0":"1","ID_NEWNOTIF":"1"},{"0":"3","ID_NEWNOTIF":"3"}]
sto visualizzando tutte le notifiche in una vista come questa:
<div class="panel-body" ng-controller="NotificationsCtrl">
<table datatable="ng" class="row-border hover">
<thead>
<tr>
<th><b>ID</b> </th>
<th><b>ID_USER</b> </th>
<th><b>DATE</b> </th>
<th><b>NOTIFICATION</b> </th>
</tr>
</thead>
<tbody>
<tr ng-repeat="data in t_notifications" ng-class="{selected: data.ID == **TO COMPLETE**>
<td>{{ data.ID }}</td>
<td>{{ data.ID_USER }}</td>
<td>{{ data.DATE }}</td>
<td>{{ data.NOTIFICATION }}</td>
</tr>
</tbody>
</table>
</div>
Mi piacerebbe sapere come è possibile selezionare nella mia tabella solo le notifiche più recenti - la ricerca attraverso l'oggetto JSON newest_notifications
- con ng-class?
PS: "selezionato" è già definito con un colore di sfondo blu.
Grazie: D Funziona perfettamente! – Ariana
È grandioso. Saluti! – potatopeelings