When I click "Cancel" in modal window, checkbox is unchecked, but it has to be checked (scope.enabledLogin has true after "Cancel" button is pressed and modal window is dismissed). Why?
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) {
});
}
}
}