npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

angular-loading-directive

v1.0.0

Published

Loading directive for AngularJS

Downloads

3

Readme

angular-loading-directive

Add the loading directive to any HTML element to make it appear whenever there is at least one pending XHR request. You can place elements wherever you like and style them with CSS animations to bring them to life. This is a simple, automatated way to give the user loading/saving feedback.

<div class="LoadingBar" loading></div>

File Size: 2.1K minified; 0.8K gzipped

Installation

  1. Install via npm
$ npm install angular-loading-directive
  1. Add zt.angular-loading as a dependency of your app
	angular.module('myApp', ['zt.angular-loading', ... ])

Usage

Add the loading directive to any element that you would like to act as a loading bar, wheel, modal, etc.

<div class="LoadingModal">
    <div class="LoadingWheel" loading>
</div>

Configuration

Adjust the latency threshold

By default, any element with the loading directive will be shown for the duration of the time there is at least one XHR request pending. If you would like to customize this and only display the loading bar for slower responses use the LoadingProvider to set this threshold.

angular.module('myApp', ['zt.angular-loading'])
    .config(function(LoadingProvider) {
        LoadingProvider.latencyThreshold = 100;
    });

Hide on certain request types

By default, the loading directive is visible when there is a pending XHR request of any type. You can configre the loading bar to only be visible while certian types of requests are pending. Perhaps you want to give the user feedback about loading but not saving so the app feels more fluid and automatic. Then restrict the request types tracked to only GET requests.

angular.module('myApp', ['zt.angular-loading'])
    .config(function(LoadingProvider) {
        LoadingProvider.requestType = ['GET'];
    });

Ignoring individual XHR requests

When your app is polling it can be very annoying to the user to keep showing the loading bar for what are supposed to be transparent updates. To ignore individual requests pass the hideLoading attribute to the $http request configuration.

$http.get('/test', {
    hideLoading: true
});
$http.patch('/test', {
    hideLoading: true
});

Manual usage

If you would like to manually show and hide your loading elements then you can use the service API.

angular.module('myApp', ['zt.angular-loading'])
    .controller('myAppcontroller', function(Loading) {
        var self = this;
        self.showLoading = function() {
            Loading.show();
        };
        self.hideLoading = function() {
            Loading.hide();
        };
        self.showLoadingFor = function(milliseconds) {
            Loading.showFor(milliseconds);
        };
    });