8

I'm using an if/else expression and a translation of the possible values inside the placeholder-Tag of an HTML input-element. It obviously doesn't work this way, because of the nested double quotes inside the placeholder-tag:

<input type="number" 
       placeholder="{{constraint ? '{{"TERM_A" | translate}}' : '{{"TERM_B" | translate}}'}}"
       ng-model="" 
       required 
       autocapitalize="none" 
       autocorrect="off" /> 

How do I set the single/double-quotes accordingly or is there even a more elegant solution?

Brendan Green
  • 11,676
  • 5
  • 44
  • 76
Felix
  • 81
  • 1
  • 3

1 Answers1

8

Proper way:

 <input type="number" 
               placeholder="{{ (constraint ? 'TERM_A' : 'TERM_B') | translate }}"
               ng-model="" 
               required 
               autocapitalize="none" 
               autocorrect="off" /> 

Another sample:

            label="{{ (detailsTriggered ? 'ui.showDetails' : 'ui.hideDetails') | translate}}"

Beware of " [ ] " braces, types of quotation marks and apostrophes.

Outside_Box
  • 447
  • 1
  • 4
  • 16