我有一个带有名称的 Angular 表单p24Form
<div ng-form="private2" name="p24Form" ng-show="freqSelect == '2.4'" novalidate="" class="ng-pristine ng-valid">
<div class="form-group">
<label class="col-sm-2 control-label">
<span class="edit" data-pk="private_2">WiFi name</span>:
</label>
<div class="col-sm-4">
<input type="text" class="form-control ng-pristine ng-untouched ng-valid" name="freq2_name" ng-model="ssid">
<!-- tooltips: -->
</div>
</div>
</div>
我正在尝试检测它是否变脏或更改,然后相应地显示我的保存按钮。我试过了
尝试#1
if ($scope.p24Form.$dirty) {
alert('dirty');
$scope.showSaveBtn = true;
}else{
$scope.showSaveBtn = false;
}
尝试#2
if ($scope.private2.$dirty) {
alert('dirty');
$scope.showSaveBtn = true;
}else{
$scope.showSaveBtn = false;
}
我一直得到
TypeError:无法读取未定义的属性“$dirty”
我该如何调试呢?