ユーザーフォームの作成に使用しようとしてng-repeat
いますが、少し苦労しています。signupForm.modelBindings
入力を配列内の名前でスコープにバインドすると、名前がinput
値として設定されますが、明らかにそれは私が望んでいるものではありません。入力を空のままにして、入力をスコープにバインドするにはどうすればよいですか?
PS:私はこれを非常に面倒な方法でやろうとしているように感じます.値を含む多くの配列を作成することなく、私が望むものを達成するためのさらに良い方法はありますか?
編集:より良い解決策を見つけましたが、入力が空でないという問題がまだあります。更新されたコードを見てください。
<tr ng-repeat="row in signupForm"
class="data-row">
<td class="label-cell data-cell">
<label ng-bind="(row.description) + ':'"></label>
</td>
<td class="data-cell">
<input type="{{row.type}}" ng-model="row.model"
placeholder="{{row.description}}"
class="round input">
</td>
<td class="error-cell data-cell">
<span class="error">*</span>
</td>
</tr>
フォームの情報:
$scope.signupForm = [
{
description: 'Firstname',
type: 'text',
model: 'user.firstname'
},
{
description: 'Lastname',
type: 'text',
model: 'user.lastname'
},
{
description: 'Date of birth',
type: 'text',
model: 'user.dateOfBirth'
},
{
description: 'Country',
type: 'text',
model: 'user.country'
},
{
description: 'Display name',
type: 'text',
model: 'user.displayName'
},
{
description: 'E-mail',
type: 'email',
model: 'user.email'
},
{
description: 'Password',
type: 'password',
model: 'user.firstname'
},
{
description: 'Confirm password',
type: 'password',
model: 'user.confirmPassword'
}
]
スコープを空の文字列に設定してクリアしようとしましたが、うまくいきませんでした:
$scope.firstname, $scope.lastname, $scope.dateOfBirth,
$scope.country, $scope.displayName, $scope.email,
$scope.password, $scope.confirmedPassword = '';