javascript-AngularJS:如何翻译md占位符?
作者:互联网
我有一个使用AngularJS的非常简单的datepicker,我想给它一个占位符,以便使用AngularJS转换它(就像我通常在我的项目中一样).
这是我的HTML代码:
<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>
这样做会引发此错误:
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”>
解决方法:
我认为您正在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>
标签:angular-translate,angularjs,datepicker,javascript 来源: https://codeday.me/bug/20191111/2020421.html