6

I have a very simple datepicker using AngularJS and I want to give it a placeholder to translate it using AngularJS translate (like I do usually in my project).

Here's my HTML code:

<div flex class="layout-row">
        <md-datepicker ng-model="vm.calendarEvent.start" ng-model-options="{ timezone: 'UTC' }" md-placeholder="Une date" translate translate-md-placeholder="PROF.SHARE.DUE">
        </md-datepicker>
</div>

Doing so throws me this error:

Error: [$compile:multidir] Multiple directives [mdDatepicker (module: material.components.datepicker), translate (module: pascalprecht.translate)] asking for new/isolated scope on:

< md-datepicker class="ng-pristine ng-untouched ng-valid _md-datepicker-has-triangle-icon" ng-model="vm.calendarEvent.start" ng-model-options="{ timezone: 'UTC' }" md-placeholder="Une date" translate="" translate-md-placeholder="PROF.SHARE.DUE">

lin
  • 17,956
  • 4
  • 59
  • 83
Orsu
  • 405
  • 6
  • 19

1 Answers1

3

I think you are looking for this inline translation on md-placeholder:

<div flex class="layout-row">
  <md-datepicker ng-model="vm.calendarEvent.start" 
                 ng-model-options="{ timezone: 'UTC' }" 
                 md-placeholder="{{ 'PROF.SHARE.DUE' | translate  }}">
  </md-datepicker>
</div>
lin
  • 17,956
  • 4
  • 59
  • 83
  • 3
    i did the change, now i got >Syntax Error: Token ''PROF.SHARE.DUE'' is not a valid identifier at column 13 of the expression [translate | 'PROF.SHARE.DUE'] starting at ['PROF.SHARE.DUE']. – Orsu Apr 05 '17 at 13:50
  • 1
    @Orsu Check the update please ... it should be `{{ 'PROF.SHARE.DUE' | translate }}` not `{{ translate | 'PROF.SHARE.DUE' }}` – lin Apr 05 '17 at 13:51
  • 3
    just checked ! works perfectly fine :) thank you (where did you learned this ?) – Orsu Apr 05 '17 at 13:51
  • 1
    @Orsu by reading the documentation https://angular-translate.github.io/docs/#/guide ;) – lin Apr 05 '17 at 13:52
  • 1
    @Orsu pushed ya ;-) ... SO needs more nice users like you. – lin Apr 05 '17 at 13:53
  • well thank you ^^ (i can't accept as answer just now i have to wait a min or something like this) -- done – Orsu Apr 05 '17 at 13:54