简体   繁体   English

选择/取消选择复选框

[英]select/ unselect checkbox angular

I'am facing a issue with Unselecting a checkbox, when the backend service fails. 当后端服务失败时,我面临取消选中复选框的问题。 It still remians selected . 它仍然是雷米安人选择的。 Here is the flow of code 这是代码流

html - html-

> <ng-repeat="rx in rxList">
>     <button toggle-switch ng-checked="rx.details.autoFillActive" ng-model="rx.details.autoFillActive" ng-click="toggleReadyFill(rx,
> $event)" ></button>

Js file - js文件-

$scope.toggleReadyFill = function(rx, $event) {
           scriptsyncService.addRx(rxList, storeDetails, syncDate).then(
                function(success) {
                    console.log('success');
                },
                function(error) {
                    $scope.selectedRx.isSelected = false;
                });
        };

the issue over here is, when we select the checkbox, we are making service call and if the service fails the checkbox still remains selected. 这里的问题是,当我们选择复选框时,我们正在进行服务调用,如果服务失败,则该复选框仍保持选中状态。 This is being unselected only on refresh of page. 仅在刷新页面时才取消选择。 How can i unselect the checkbox upon service failure 服务失败后如何取消选中该复选框

我认为您应该设置rx.details.autoFillActive的值,而不是$scope.selectedRx.isSelected的值,因为您要将此表达式用于ng-model并进行ng-checked

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM