Orsu
Orsu

Reputation: 417

AngularJS: How to translate a md-placeholder?

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">

Upvotes: 6

Views: 995

Answers (1)

lin
lin

Reputation: 18392

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>

Upvotes: 3

Related Questions