Currently, I am using the function checkDevice(obj)
to validate if a value is present or not. In addition to this functionality, I also require a separate method to determine the number of occurrences of Device in the Array
.
component.ts
public checkDevice(obj) {
if (obj == null || obj == '' || obj == '-1') {
return false;
} else {
return true;
}
}
component.html
<div class="float-left" *ngIf="checkDevice(obj.device_token) == true">
<i class="fa fa-icon" aria-hidden="true"></i>
</div>
Edit the PHP script responsible for database queries.
$users = array();
if ($results = $dbh->runQuery($sql)) {
foreach ($results as $key=>$row){
$users[$row['user_id']][] = array('user_id'=>$row['user_id'],
'user_token' => $row['utoken'],
'device_token' => $row['device'],
'group_name' => $row['group_name']);
}
}