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

0

I'm doing a ToDo and I need to define it in priority (urgent, high, medium and low). But I can only define by integer (1 is urgent, 2 is high etc)

The question is: can you show another value in html but assign it to the original in the bank? Example:

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

If it's possible, how do I do it?

    
asked by anonymous 25.10.2017 / 20:05

1 answer

0

You can create a filter in Angular to display the text you want based on the index you set for 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>
    
25.10.2017 / 21:38