我有4个角形式和一个保存按钮
保存按钮
<div class="col-sm-2">
<button class="btn btn-sm btn-primary pull-right admin-hide mb10" ng-show="showSaveBtn == true" ng-click="checkSaveBtn()">Save</button>
</div>
4表格
{{-- WiFi Includes --}}
@if($section == "private")
<div ng-form="private2" name="p24Form" ng-show="freqSelect == '2.4'" novalidate>
@include('views.settings.wifi.private2')
</div>
<div ng-form="private5" name="p50Form" ng-show="freqSelect == '5'" novalidate>
@include('views.settings.wifi.private5')
</div>
@elseif($section == "guest")
<div ng-form="guest2" name="g24Form" ng-show="freqSelect == '2.4'" novalidate>
@include('views.settings.wifi.guest2')
</div>
<div ng-form="guest5" name="g50Form" ng-show="freqSelect == '5'" novalidate>
@include('views.settings.wifi.guest5')
</div>
@endif
我试图在这4个表单中的一个更改后立即检测并显示我的保存按钮。
我试过
$scope.showSaveBtn = false;
$scope.checkSaveBtn = function() {
if (
$scope.p24Form.$dirty ||
$scope.g24Form.$dirty ||
$scope.p50Form.$dirty ||
$scope.g50Form.$dirty
) {
$scope.showSaveBtn = true;
}else{
$scope.showSaveBtn = false;
}
}
console.info('$scope.showSaveBtn = ', $scope.showSaveBtn);
$scope.showSaveBtn
一直不假......
为什么它会继续返回false?我做错了什么 ?
如何进一步调试?
ngChange-like functionality for the entire form
没有回复我的帖子。根据链接,人们使用标签,但在我的情况下,我使用带有ng-form
属性的标签,我们用来检查它的方式可能略有不同。