Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on server deployment doesn't show model value #41

Open
firatkucuk opened this issue Jan 24, 2017 · 0 comments
Open

on server deployment doesn't show model value #41

firatkucuk opened this issue Jan 24, 2017 · 0 comments

Comments

@firatkucuk
Copy link

My web app has tons of controller and JS stuff included. So checkbox always show false state. But when I give delay for initialization it works well.

function initializeSwitch() {
  $timeout(function() {
    // Remove any old switcher
    if (switcher) {
      angular.element(switcher.switcher).remove();
    }
    // (re)create switcher to reflect latest state of the checkbox element
    switcher = new $window.Switchery(elem[0], options);
    var element = switcher.element;
    element.checked = scope.initValue;
    if (attrs.disabled) {
      switcher.disable();
    }

    switcher.setPosition(false);
    element.addEventListener('change',function(evt) {
        scope.$apply(function() {
            ngModel.$setViewValue(element.checked);
        })
    });
    scope.$watch('initValue', function(newValue, oldValue) {
        switcher.setPosition(false);
    });
  }, 200); // <-- changed value 0 to 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant