DailyJS

ngActivityIndicator, angular-cog, dijs

2014-05-26 00:00:00 +0100 by Alex R. Young

ngActivityIndicator

ngActivityIndicator

ngActivityIndicator (GitHub: voronianski / ngActivityIndicator, License: MIT) by Dmitri Voronianski is an Angular provider for loading indicators, which you can use on directives, controllers or services.

Adding an indicator to a controller looks like this:

var app = angular.module('exampleApp', ['ngActivityIndicator']);

app.controller('MainCtrl', ['$activityIndicator', '$timeout',
  function ($actvityIndicator, $timeout) {
    $actvityIndicator.startAnimating();
    $timeout(function () {
      $actvityIndicator.stopAnimating();
    }, 3000);
  }
]);

There's a directive called ng-activity-indicator which can be used to inject the indicator into the DOM automatically.

angular-cog

angular-cog (GitHub: chinmaymk / angular-cog, License: MIT) by Chinmay Kulkarni is a library for writing declarative Ajax requests with Angular.

The full set of directives are as follows:

<div cog-verb="{url}"
        cog-model="{ng-model}"
        cog-success="{angular.expression}"
        cog-error="{angular.expression}"
        cog-trigger="{angular.expression}"
        cog-no-spinner="{true|false}"
        cog-absolute-url="{true|false}"
        cog-config="{object}">
</div>

Requesting JSON content should place it in the $data variable, so you can access it in cog-success and then pass it to something bound in $scope.

The documentation includes notes on how to set up a loading indicator -- maybe you could try ngActivityIndicator?

dijs

dijs (GitHub: cmtt / dijs, License: WTFPL) by Matthias Thoemmes is a dependency injection module for Node and browsers that's inspired by Angular. There are methods for defining a namespace, describing the modules, and resolving dependencies.

For describing dependencies, it supports function notation and array notation:

// Function notation
var mod = Di();
mod.provide('Pi', Math.PI, true);
mod.provide('2Pi', function(Pi) { return 2*Pi; });

// Array notation
var mod = Di();
mod.provide('Math.Pi', Math.PI, true);
mod.provide('2Pi', ['Math.Pi', function (Pi) {
  return function () {
    return 2*Pi;
  };
}]);

There's a lot more to it than this, and you might find it useful if you've got used to DI through Angular but want to use it elsewhere.