Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70612

Ng-change, change scope variable, does not update UI

$
0
0

@ZephDavies wrote:

Hi

I have a toggle, which when set to "true" gives the user a confirm dialog.
If the user cancels, the UI toggle does not revert to false.
I've attempted to use $scope.apply(), but it says it is already applying.

HTML:

<ion-toggle ng-model="useMobileData"
            ng-change="updateMobileData(useMobileData)">
    <b>Use Mobile Data</b>
</ion-toggle>

Javascript:

$scope.useMobileData = false;
$scope.updateMobileData = function (bool) {
    if (bool) {
        bool = confirm("Using Mobile Data may incur a cost, depending on your tariff");
    }
    //$scope.$apply(function () {
    $scope.useMobileData = bool;
    //});
};

Any help is appreciated!

EDIT:
Added a Code Pen:
http://codepen.io/anon/pen/ZbBzxM

I assume this is due to ng-model.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70612

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>