AngularJS翻译不适用于占位符

时间:2016-09-06 05:35:38

标签: javascript html css angularjs json

我正在使用在AngularJS中开发的clip-2,其中我使用的是使用JSON文件的翻译多语言,它适用于所有HTML标记,但是当我尝试使用它来翻译占位符时它不起作用。

JSON格式

"addemployee": {
  "Name": "Name",
  "Typename": "Type name",
  "Employeid": "Employe id",
  "Username": "Username",
  "Contactno": "Contact no.",
  "Typecontactno": "Type contact no.",
  "Password": "Password",
  "Typepassword":"Type password",
  "Confirmpassword": "Confirm password",
  "Selectimagefile": "Select an image file",
  "remove": "Remove",
  "cancel": "Cancel",
  "upload": "Upload",
  "Addemployee": "Add employee",
  "TypeConfirmpassword": "Type Confirm password"
}

适用于HTML标记

<h1 class="mainTitle" translate="addemployee.Addemployee"> Add Employee</h1>

但在输入占位符

中不起作用
placeholder=""

1 个答案:

答案 0 :(得分:0)

你确实尝试过这样吗?

<input type="text" ng-attr-placeholder="{{ 'addemployee.Addemployee' | translate }}" name="firstName" ng-model="employee.name" id="name" class="form-control" required>

"addemployee": { 
    "Name": "Name", 
    "Typename": "Type name", 
    "Employeid": "Employe id", 
    "Username": "Username", 
    "Contactno": "Contact no.", 
    "Typecontactno": "Type contact no.", 
    "Password": "Password", 
    "Typepassword":"Type password", 
    "Confirmpassword": "Confirm password", 
    "Selectimagefile": "Select an image file", 
    "remove": "Remove", 
    "cancel": "Cancel", 
    "upload": "Upload", 
    "Addemployee": "Add employee", 
    "TypeConfirmpassword": "Type Confirm password" 
}

修改

ng-show

您必须使用条件进行两次翻译,例如ng-hide或{{1}}。