New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

gm.waits-for

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gm.waits-for

AngularJS module that displays a message in place of an element while a value it depends on loads asynchronously.

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

gm.waitsFor

AngularJS directive that automatically shows a message or template while a value is loaded asynchronously.

I found I was always making a second element with the inverse ngIf statement from an element where I show data that would just say 'Loading...'.

The waitsFor directive takes care of this automatically, optionally putting in a custom message or template.

Usage

Say you have some data you're loading asynchronously. You can use the waitsFor directive to show the element that uses the data only when it's ready and give the user feedback while it's loading:

<div waits-for='items'>
  <div ng-repeat='item in items'>
    ...
  </div>
</div>

The directive is similar to ngShow in that it hides the inner HTML of the element until the property is truthy using the 'ng-hide' CSS class. Because of this, the contents have to be inside elements to be hidden. Text nodes will be unaffected.

By default, it will just show <span>Loading...</span>. You can also provide your own default template using waitsForConfigProvider.

You can also add an attribute waits-for-template to show a non-default template, or waits-for-template-url to load a non-default template from a file or from $templateCache. A template from a URL takes precedence over a string template.

The watcher that checks the value passed in to the waitsFor attribute is automatically cancelled after the value resolves to a truthy value. To keep the watcher active, set the waitsForPersist attribute to a truthy value.

Examples

Run npm start and navigate to the 'example' directory to view examples showing different ways to use gm.waitsFor.

Demo

View on Plunker

Thanks to @tobiasahlin for spinner.

Keywords

FAQs

Package last updated on 02 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc