Hi Sander,
Here is the steps about what i am trying to do -
My requirement in brief -
If a particular timestamp property of a JSON array object is different from
the current timestamp by 15 minutes or less, i need to
highlight/continuously blink the corresponding table(which loads the JSON
array object) row on the Template UI.
1. I check for a datetime field within a JSON object and subtract it with
current datetime by converting both(former and latter) into milliseconds in
my component.
// Check for actively running venues
this.filteredVenues.forEach((ven, index) => {
if (tm.getTime() - (new Date(ven.lastheartbeat).getTime()) <= 900000) {
this.venuesRunning.push(index);
}
console.log(this.venuesRunning);
});
2. If the difference is lesser than 900000 milliseconds, i capture the
index of the json sub object and push the same into a component array field
venuesRunning: any = []; // running state of venue
3. On the UI template i have a table which will parse my JSON object and
load all its content. However, if any of the row index of the table,
matches with the contents/indexes of component array, i need to
highlight/blink only those particular rows.
<tr *ngFor="let v of mf.data; index as i" [class.bg-primary]=
"venuesRunning.includes(v)">
<td>{{i}} {{v.name}}</td>
<td>{{v.address}}</td>
<td>{{v.description}}</td>
.....
The solution you provided seems to be not working for my requirement. It
was my bad that i did not put things properly before. Please let me know if
that made sense or i need to explain more better.
Thanks,
Rohit
On Sunday, February 10, 2019 at 9:24:27 AM UTC-6, Sander Elias wrote:
>
> Hi rj,
>
> try:
>
> [class.bg-primary]="venuesRunning.includes(v)">
>
> (you might want ti use i insteadn of v I’m not sure what you are trying
> to do.
>
> Regards
> Sander
>
>
--
You received this message because you are subscribed to the Google Groups
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.