After clicking "Cancel" in the modal window, the checkbox is unchecked even though it should remain checked (the scope.enabledLogin value is true after pressing the "Cancel" button and dismissing the modal window). Why is this happening?
Jade:
.checkbox(ng-show="showEnabledLogin", ng-class="{'disabled': (!email.length || userForm.email.$error.email)}")
label(for="enabledLogin")
input(ng-show="showEnabledLogin", type="checkbox", id="enabledLogin", name="enabledLogin", ng-model="enabledLogin", ng-disabled="(!email.length || userForm.email.$error.email)", ng-change="showEnabledLoginModal()")
span Player login enabled
JS:
scope.isEnabledLoginManuallyUnchecked = false;
function checkIfEnabledLoginManuallyUnchecked() {
if(scope.isEnabledLoginManuallyUnchecked) {
scope.showEnabledLogin = false;
scope.showInviteLogin = true;
scope.enabledLogin = false;
} else {
scope.showEnabledLogin = true;
scope.showInviteLogin = false;
scope.enabledLogin = true;
}
}
var enabledLoginModal,
modalScope;
var isOpened = false;
scope.showEnabledLoginModal = function () {
if (isOpened) return;
if ((scope.email.length || scope.userForm.email.$error.email)) {
if (scope.enabledLogin) {
debugger;
var child = scope.$new();
var extension = {
cancel: function (e) {
scope.isEnabledLoginManuallyUnchecked = false;
checkIfEnabledLoginManuallyUnchecked();
enabledLoginModal.dismiss(e);
isOpened = false;
},
modal: {
title: 'Please confirm'
}
};
modalScope = angular.extend(child, extension);
var modalOptions = {backdrop: 'static', templateUrl: 'app/player/edit/show-enabled-login-modal.html'};
enabledLoginModal = Modal.custom(modalOptions, modalScope, 'modal-danger');
isOpened = true;
enabledLoginModal.result.then(function (result) {
});
}
}
}