ng-repeat 中的 ng-model 正在失去焦点
ng-model inside ng-repeat is losing focus
在我的JavaScript中,我有
$scope.newQuestion = {
answers: []
};
我的HTML是
<div class="row" ng-repeat="answer in newQuestion.answers">
<div class="input-field col m12">
<input id="answer{{ $index }}" type="text" class="validate" ng-model="newQuestion.answers[$index]">
</div>
</div>
每当我输入内容时,它都会在输入框中失去焦点。
原来我需要做:
<div class="row" ng-repeat="answer in newQuestion.answers track by $index">
在我的JavaScript中,我有
$scope.newQuestion = {
answers: []
};
我的HTML是
<div class="row" ng-repeat="answer in newQuestion.answers">
<div class="input-field col m12">
<input id="answer{{ $index }}" type="text" class="validate" ng-model="newQuestion.answers[$index]">
</div>
</div>
每当我输入内容时,它都会在输入框中失去焦点。
原来我需要做:
<div class="row" ng-repeat="answer in newQuestion.answers track by $index">