jeudi 28 mai 2015

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 -

> <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 -

$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




Aucun commentaire:

Enregistrer un commentaire