No description, website, or topics provided.
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bower_components
README.md
bower.json
janrainconfig.js

README.md

Angular Module for Janrain Configuration

Usage

1. Install the module:

bower install --save janrain/angular-janrainconfig

2. Add to scripts in html:

<script src="bower_components/angular-janrainsso/janrainconfig.js"></script>

3. Add to angular dependencies and configure the module in the angular config block:

E.g. in app.js:

angular.module('myApp', ['myApp.controllers', 'myApp.services', ... 'janrainConfig'])
.config(function (..., janrainConfigProvider) {
  janrainConfigProvider.setConfUrl('/ops/config');
  ...
}

You can also set or override any explicit configuration in the config block:

janrainConfigProvider.set('foo', 'bar'); // where 'foo' is the key and 'bar' is the value

4. Get configuration values:

app.factory('SomeFactory', function(janrainConfig) {

/*   Angular doesn't have a mechanism to
 *   resolve service dependency promises
 *   yet, so you have to do this manually:
 */

  janrainConfig.then(function(config) {

    var apiUrl = config.get('apiUrl'); // returns e.g. '/api/'
    var configObject = config(); // returns JSON object with all available configs

  });

});

/*   You can however, resolve them in a
 *   resolve object of a route:
 */

$routeProvider
  .when('/', {
    templateUrl: 'views/main.html',
    controller: 'MainCtrl',
    resolve: {config: 'janrainConfig'}
  })

/*   Then the resolved config object will be
 *   available as an injected dependency:
 */

app.controller('MainCtrl',  function ($scope, config) {
  var foo = config.get('foo'); // returns 'bar'
});