在這里使用 angularjs。我有一個表格,其中使用在單擊(+)按鈕時添加由 2 個輸入文本組成的動態(tài)行。在完成(提交)按鈕上添加行后,我想驗證輸入。我確實看到我的驗證正常,但它沒有突出顯示有錯誤的行。這是我的代碼: <table class="table table-borderless" ng-if="options.length>0"> <thead> <tr> <td class="bold">Key</td> <td class="bold">Value</td> </tr> </thead> <tbody style="border: none;"> <tr ng-repeat="m in options"> <td ng-class="{ 'has-error': paramForm['ctrlKey_' + {{$index}}].$invalid && (paramForm['ctrlValue_' + {{$index}}].$touched || paramForm.$submitted) }"> <input type="text" name="ctrlKey_{{$index}}" class="form-control" ng-model="m.optionText" required /> </td> <td> <input type="text" class="form-control" ng-model="m.optionValue" required /> </td> <td> <a class="btn btn-xs" ng-click="Remove($index)"><i class="glyphicon glyphicon-trash"></i></a> </td> </tr> </tbody> </table>我認(rèn)為添加以下行會使我的 TD 突出顯示為紅色,但這不起作用。ng-class="{ 'has-error': paramForm['ctrlKey_' + {{$index}}].$invalid && (paramForm['ctrlValue_' + {{$index}}].$touched || paramForm.$submitted) }"這里有什么遺漏嗎?
Angularjs 驗證和突出顯示 ng-repeat 中的輸入
紫衣仙女
2021-06-01 14:45:14