ons-switch


  • Onsen UI

    Switch component.

    Click here to see the original article



  • hi friends,

    I added my switch in html like this:
    <ons-switch var=“mySwitch” modifier=“list-item”></ons-switch>

    I tried to set switch status from my angular controller but on start it says it is undefined. I think controller works before it install itselfs.

    I tried this: $scope.$on(’$viewContentLoaded’) and this: ons.ready() but both of them didn’t help.

    Finnaly I created a loop and checked it in every 10 miliseconds then I do my stuff. It worked for me but I think that for sure there is a better solution (with ng-model or etc) but I didn’t find it.

    Has anyone idea about this?
    My custom loop looks like this:

    var waitTillContentLoaded = setInterval(function(){
        if(mySwitch){
    
            // update
            mySwitch.on('change', function(){
                // ...
            });
    
            // clear loop
            clearInterval(waitTillContentLoaded);
        }else{
            console.log("nope");
        }
    }, 10);
    

    By the way, this textarea has to be heigher…


  • Onsen UI

    @serdarde Which version are you using? I noticed a bug like this but I think it was fIxed in beta.8. If you can make a Codepen example we could test it easier. About the textarea, you can resize it as any other HTML textarea. Just drag it :sweat_smile:


Log in to reply