Giter Club home page Giter Club logo

Comments (9)

johannesjo avatar johannesjo commented on May 21, 2024

Hello there! Thanks for reporting! I made a commit which allows you to configure the button selector via the BTN_SELECTOR property of the config.

If this doesn't work: Could you by any chance provide a plunkr or something of the sort illustrating the issue?

from angular-promise-buttons.

tooppaaa avatar tooppaaa commented on May 21, 2024

Hello !

I applied you commit but it didn't fixed the issue.
I created the plunker : https://plnkr.co/edit/G2s27apA7h84ueviCHjI?p=preview

You just have to click "Login"
i haven't created any factory to have a proper promise as this is not needed there. If the form is valid, everything works fine.

from angular-promise-buttons.

johannesjo avatar johannesjo commented on May 21, 2024

The answer is simple: You're not giving the button any type of promise. Imho otherwise you won't need a loading spinner anyways, as the action is happening instantly. See this example: https://plnkr.co/edit/i51lgyIs9hSqhSiJ5UTG?p=preview

from angular-promise-buttons.

johannesjo avatar johannesjo commented on May 21, 2024

To quote the Readme you need to do one of the two:

// inside some controller
$scope.yourServiceCaller = function ()
{
  // needs to return a promise
  return fakeFactory.method().then(...);
};
// or 
// inside some controller
$scope.yourServiceCaller = function ()
{
  // needs to be a promise
  $scope.yourPromise = fakeFactory.method().then(...);
};

from angular-promise-buttons.

tooppaaa avatar tooppaaa commented on May 21, 2024

When the form is valid, there are no issues with a valid promise.
I did not add any as this is not needed to reproduce.

However, if you open the plunkr, hit login with an empty password, the login method is not called (you don't see the alert, the promise is not returned to the button) but the spinner is displayed.

I tried on Chrome & Edge, same behaviour.

Edit : I have a solution, let me create a PR :)

from angular-promise-buttons.

tooppaaa avatar tooppaaa commented on May 21, 2024

PR : @ #34

from angular-promise-buttons.

johannesjo avatar johannesjo commented on May 21, 2024

Thank you for the pr. I'm not really sure, if I want to add form validation checks with this directive though as there might be unintended side effects (usually I handle validation with ng-fab-form). My first thought would be to pass the promise to the directive directly (e.g.: <button promisie-btn=promise>) and only assign the promise/make the asynchronous call when the form is valid. I've to think about it though. I'll get back to you.

from angular-promise-buttons.

johannesjo avatar johannesjo commented on May 21, 2024

I debugged the issue a little further: This only occurs together when the option addClassToCurrentBtnOnly is set to true. You usually don't need this. Only for the rare cases when you have multiple promise-btns for the same promise, but you just want to show the spinner on the currently clicked one.

from angular-promise-buttons.

tooppaaa avatar tooppaaa commented on May 21, 2024

Good spot ! I guess I misunderstood the addClassToCurrentBtnOnly option.
I thought I was able to disable other buttons by specifying the same promise.

You can reject my PR, I'll set the option to false and think a bit more of how to disable the other buttons of the form while waiting for the promise.

Thanks for your help !

from angular-promise-buttons.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.