johannesjo / angular2-promise-buttons

Chilled loading buttons for angular2
https://johannesjo.github.io/angular2-promise-buttons/#demo
MIT License
86 stars 28 forks source link

Does this work with system.js? #4

Closed jelling closed 7 years ago

jelling commented 7 years ago

TIL. I'm getting a weird issue when I try loading the dist/index.js file via system.js.

My systemJs file:

` map: { // our app is within the app folder app: 'app', 'angular2-promise-buttons': 'npm:angular2-promise-buttons/dist/index.js' }

`

But when I run it in the browser it requests "/angular2-promise-buttons/dist/index.js/dist.js", which obviously isn't there.

I am using Angular 2.4 with version 1.0.7 of your project.

johannesjo commented 7 years ago

That's weird indeed. Is this module the only one giving you trouble? Unfortunately I'm not too experienced with systemjs, but if you have some actual example code, I can have a look at it.

jelling commented 7 years ago

Yeah, only this module.

Do you have a compiled version anywhere on the web? I might just link to it for now. We may switch to another module loader soon.

johannesjo commented 7 years ago

No unfortunately not. But I can try to build one tomorrow.

Just a wild guess: How do you import the module? Like this?

import {Angular2PromiseButtonModule} from 'angular2-promise-buttons/dist';

Maybe changing this to

import {Angular2PromiseButtonModule} from 'angular2-promise-buttons';

helps?

jelling commented 7 years ago

That was it! Thanks man. And thanks for building this.

jelling commented 7 years ago

One other note: the docs have a bug in them. The following code needs the {} inside forRoot()

    Angular2PromiseButtonModule
      .forRoot({
        // your custom config goes here
        spinnerTpl: '<span class="btn-spinner"></span>',
        // disable buttons when promise is pending
        disableBtn: true,
        // the class used to indicate a pending promise
        btnLoadingClass: 'is-loading',
        // only disable and show is-loading class for clicked button, 
        // even when they share the same promise
        handleCurrentBtnOnly: false,
  })