angular-promise-messages
The promiseMessages
module provides enhanced support for displaying messages depending on some promise within templates.
Installation
install via npm
npm install angular-promise-messages --save
install via bower
bower install angular-promise-messages --save
Add promiseMessages
as dependency in your module:
angular;
// es6 way; angular;
Usage
Basic usage
Use the attribute for
to pass a promise to a directive. Then the directive starts watching the promise.
<!-- Default message --> Default <!-- Pending message --> Pending <!-- Fulfilled message --> Fulfilled <!-- Rejected message --> Rejected
{ // Passing a promise object to the `for` attribute // of the `promiseMessages` directive $scopepromise = $http;}
Function support
Use the attribute forAction
when you want to pass a promise which will be returned by a function.
Default Pending Fulfilled Rejected
{ // Passing a promise object to the `forAction` attribute // of the `promiseMessages` directive by returning promise. return $http;}
Theming
If the state
attribute is specified, current state will be published into related scope.
Then, you can theme it as you want by using published states.
Default Pending Fulfilled Rejected
Auto resetting state
Resetting a promise state automatically when the state is changed by configuring delays until reset.
It is useful if want to reset a message when a promise state was changed (such as rejected).
Configure globally
Overriding global configurations
disableAutoReset
: Disable auto resettingautoResetDelay
: Override auto resetting delay
Default Pending <!-- Disable auto resetting --> Fulfilled <!-- Override auto resetting delay --> Rejected
Contribution
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D