How to start spinner on ons-button Onsen UI 1



  • I’ve got an ons-button element

    <ons-button modifier="large--cta" ng-click="login($event, input.email, input.password)">Log In</ons-button>

    And a function (login) that is attempting to use the startSpinner() method of OnsenUI’s ons-button to start a spinner on the button to show the user that the app is working on their request.

    I’ve tried the following without success. None of these functions are defined per the console.

    event.currentTarget.startSpin()

    event.target.startSpin()

    ons.startSpinn(event.currentTarget)

    startSpinn(event.currentTarget)

    How do I go about starting a spinner on the button?

    The behavior I want is for the user to tap a button and for the spinner to start (or for the button to disable) so that they know the app is processing their request.

    Any advice would be greatly appreciated



  • @Steven-Sokulski Are you using version 1 or version 2 of Onsen?


  • Onsen UI

    @Steven-Sokulski
    Simply use the var attribute.
    <ons-button var="myButton" ng-click="myButton.startSpin(); doStuff()">Click here</ons-button>

    This is only for Onsen UI v1. It was removed from v2.


Log in to reply