ng-submission
Keep track of pending/error states in Angular
Inspired by bendrucker/submission.
Install
$ npm install --save ng-submission
Usage
angular { var self = this var submission = this { console // => {pending: false, error: null} const promise = submission console // => {pending: true, error: null} return promise }}
Setup
Include 'ng-submission' in your angular module's dependencies:
// node module exports the string 'ng-submission' for convenienceangular// otherwise, include the code first then the module nameangular
API
ngSubmission
: function ()
-> submission
service: Exposes the 'ngSubmission' service, which is a function that returns a new submission
instance.
submission
Is an object, with three properties:
submission.submit: function(promise)
- A function that takes a promise and starts a new submission.submission.pending: Boolean
- whether the submit is pendingsubmission.error: Object|null
- if the previous submit errored, the error object from that submission. Otherwise, null.
License
MIT © Andrew Joslin