Is it possible to visually display another value for a certain value in the bank?

Asked

Viewed 43 times

0

I’m doing a Todo and I need to set priority (urgent, high, medium and low). But I am only able to define through integer (1 is urgent, 2 is high etc)

The question is: is it possible to show another value in html but what do you assign to the original in the database? Example:

If in the mongodb table 1 is saved, I want the result of the html query to appear "URGENT".

If possible, as I do?

1 answer

0


You can create a filter in Angular to display the text you want based on the index you set to the priority:

angular
  .module('nomedoapp')
  .filter('prioridadeFilter', function() {
    return function(input) {

      if (input === 1) return 'Urgente'
      if (input === 2) return 'Alta'
      if (input === 3) return 'Média'
      if (input === 4) return 'Baixa'

      return 'Desconhecida'
    }
  })

You could then use this filter whenever you want to display the priority text instead of the integer value:

<p>
   {{ tarefa.indice_prioridade | prioridadeFilter }}
<p>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.