A
A
Adel Khalitov2019-02-27 13:57:38
JavaScript
Adel Khalitov, 2019-02-27 13:57:38

How to compare the data and display the result?

An object comes to me from the database, conditionally:

obj = {
action: 'meet'
}

There is also an array:
PanelControl: Array<Object> = [
    {action: 'call', translate: 'Звонок'},
    {action: 'meet', translate: 'Встреча'},
    {action: 'task', translate: 'Задача'},
  ];

Now I get an object from the database naturally in this way:
<div class="wrapp" *ngFor='let x of obj'>
      <span>{{x.action}}</span>
</div>

And naturally the result of "meet" is displayed, how to make a matched output of the result so that "Meeting" is displayed.
It's the same with dates.
I display the date, conditionally 02/27/2019 (the full date format from the database in iso ), and if today is 02/27/2019 I want to display "Today", not the date.
How can this be implemented? Nothing comes to mind

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Larisa .•º, 2019-02-28
@SaveLolliPoP

В Angular 6.1 был KeyValuePipe, который позволяет выполнять итерацию свойств объекта:

<div *ngFor="let x of object | obj">
  {{x.key}}:{{x.value}}
</div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question