All Projects → johannesjo → Angular Promise Buttons

johannesjo / Angular Promise Buttons

Licence: mit
Chilled loading buttons for AngularJS

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Angular Promise Buttons

Angular Query Builder
Dynamic query building UI written in Angular.
Stars: ✭ 211 (+35.26%)
Mutual labels:  angular-directives, angularjs
ng-contenteditable
ng-contenteditable
Stars: ✭ 41 (-73.72%)
Mutual labels:  angularjs, angular-directives
Ngx Quill Editor
🍡@quilljs editor component for @angular
Stars: ✭ 234 (+50%)
Mutual labels:  angular-directives, angularjs
Angular Fx
Angular CSS3 animation directives (ngfx-bounce, ngfx-shake, ngfx-flip, ngfx-pulse and more ...) https://720kb.github.io/angular-fx
Stars: ✭ 181 (+16.03%)
Mutual labels:  angular-directives, angularjs
Angular Prest
pREST component for Angular
Stars: ✭ 16 (-89.74%)
Mutual labels:  angular-directives, angularjs
angular-downloader
Angular Downloader is an angularjs directive that enables you to manage browser download - https://720kb.github.io/angular-downloader
Stars: ✭ 16 (-89.74%)
Mutual labels:  angularjs, angular-directives
ADM-treeView
Pure AngularJs TreeView
Stars: ✭ 30 (-80.77%)
Mutual labels:  angularjs, promise
angular-openweather-app
A weather forecast app written in AngularJS
Stars: ✭ 54 (-65.38%)
Mutual labels:  angularjs, angular-directives
Angular Datepicker
Angularjs datepicker module, generate a datepicker on your input element - https://720kb.github.io/angular-datepicker
Stars: ✭ 486 (+211.54%)
Mutual labels:  angular-directives, angularjs
Angular Tooltips
Angularjs tooltips module, add tooltips to your elements - https://720kb.github.io/angular-tooltips
Stars: ✭ 357 (+128.85%)
Mutual labels:  angular-directives, angularjs
Semanticui Angular
Angular Directives for Semantic UI
Stars: ✭ 58 (-62.82%)
Mutual labels:  angular-directives, angularjs
Jocs.github.io
💯Jocs 的个人博客,所有的文章都在 issues 里面
Stars: ✭ 840 (+438.46%)
Mutual labels:  promise, angularjs
Angular1 Async Filter
Angular2 async pipe implemented as Angular 1 filter to handle promises & RxJS observables
Stars: ✭ 59 (-62.18%)
Mutual labels:  promise, angularjs
Tascalate Concurrent
Implementation of blocking (IO-Bound) cancellable java.util.concurrent.CompletionStage and related extensions to java.util.concurrent.ExecutorService-s
Stars: ✭ 144 (-7.69%)
Mutual labels:  promise
Mean Blog
Blog using Nodejs, Expressjs, Angularjs and Mongodb. MEAN Javascript Fullstack application
Stars: ✭ 151 (-3.21%)
Mutual labels:  angularjs
Blur Admin
AngularJS Bootstrap Admin Panel Framework
Stars: ✭ 11,274 (+7126.92%)
Mutual labels:  angularjs
Translatr
💬 Translate to multiple languages at once
Stars: ✭ 145 (-7.05%)
Mutual labels:  angularjs
Pagermon
Multimon-ng pager message parser and viewer
Stars: ✭ 154 (-1.28%)
Mutual labels:  angularjs
Angularjs Typescript Webpack
AngularJS 1.7, typescript 3 and webpack 4 starter project based on angular tutorial
Stars: ✭ 150 (-3.85%)
Mutual labels:  angularjs
Musicplayer
A minimal music player built on electron.
Stars: ✭ 145 (-7.05%)
Mutual labels:  angularjs

npm version Build Status Coverage Status

angular-promise-buttons

Chilled Buttons for AngularJS

For Angular 2+ version go here.

There are cool loading buttons out there for angular. Only thing which annoys me, is that you (most of the times) have to manually trigger their loading state via a boolean which leads to a bit of repetition, declaring those again and again. angular-promise-buttons exists to take away some of that, by handling the loading state directly by passing the promise. Saves you at least two lines of code every time. Check out the DEMO!

Also you can play with the code on Plnkr.

Bug-reports or feature request as well as any other kind of feedback is highly welcome!

getting started

Install it via bower or npm

bower install angular-promise-buttons -S
# or via npm
npm install angular-promise-buttons -S

and add angularPromiseButtons as dependency in your main module:

angular.module('yourApp',[
  'angularPromiseButtons'
]);

Using the buttons is easy. Just return the promise in question in your service caller and you're good to go: You can also directly return the promise via the function passed to ng-click:

<button ng-click="yourServiceCaller()"
        promise-btn>Click me to spin!</button>
// inside some controller
$scope.yourServiceCaller = function ()
{
  return fakeFactory.method().then(...);
};

using it for forms

For using the promise buttons with ng-submit you need to apply them to the form directive and add `type="submit" to the buttons you want to show a loader for:

<form ng-submit="yourServiceCaller()"
      promise-btn>
  <button type="submit">MyBtn</button>
</form>
// inside some controller
$scope.yourServiceCaller = function ()
{
  return fakeFactory.method().then(...);
};

alternative syntax and using $event

There is also an alternative syntax, which allows you to share promises between buttons (and possibly other directives) and is especially useful, if you want to use the $event somehow:

<button ng-click="yourServiceCaller($event)"
        promise-btn="yourPromise">MyBtn</button>

Now you just have to assign a promise to yourPromise:

// inside some controller
$scope.yourServiceCaller = function ()
{
  $scope.yourPromise = fakeFactory.method().then(...);
  // this is now also possible
  $event.preventDefault();
};

styling the button

The base-styles might not be overwhelmingly sexy, but it is easy to fix that! There are lots of free css-spinners out there. Just find one of your liking and add the css.

Ressources:

configuration

There are also some defaults for you to set, if you like. You can do this by using the angularPromiseButtonsProvider:

angular.module('exampleApp', [
  'angularPromiseButtons'
])
.config(function (angularPromiseButtonsProvider)
{
  angularPromiseButtonsProvider.extendConfig({
    spinnerTpl: '<span class="btn-spinner"></span>',
    disableBtn: true,
    btnLoadingClass: 'is-loading',
    addClassToCurrentBtnOnly: false,
    disableCurrentBtnOnly: false,
    minDuration: false,
    CLICK_EVENT: 'click',
    CLICK_ATTR: 'ngClick',
    SUBMIT_EVENT: 'submit',
    SUBMIT_ATTR: 'ngSubmit',
    BTN_SELECTOR: 'button'
  });
});

change options via promise-btn-options

You can also change all the options (but not the spinner template) by specifying the options via promise-btn-options:

<button class="btn"
        ng-click="yourServiceCaller()"
        promise-btn-options="options"
        promise-btn="yourPromise">MyBtn <span>Look I'm nested content</span>
</button>

Now you just have to assign a promise to yourPromise:

// inside some controller
$scope.options = {
  disableBtn: false,
  btnLoadingClass: 'is-spinning'
};
$scope.yourServiceCaller = function ()
{
  $scope.yourPromise = fakeFactory.method().then(...);
};

Thats all the logic there is (for now). Adjusting the look and feel of the spinner can be done using your own styles.

❤ contribute ❤

I'm happy for any issue or feature request, you might encounter or want to have. Even a one liner is better, than no feedback at all. Pull requests are also highly welcome. Just fork the repository, clone it and run grunt serve for development. Another important factor is the number of developers using and thus testing angular-promise-buttons. Tell your fellow programmers, say that you use it on ng-modules, tweet or even blog about it.

angular-promise-buttons is published under the The GNU Lesser General Public License V2.1.

(possible) promising future features

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].