Skip to content

An AngularJS module that can be used to hide/exclude application features until they are ready.

Notifications You must be signed in to change notification settings

iluxav/angular-feature-flags

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Coverage Status

angular-feature-flags

An AngularJS module that allows you to control when you release new features in your app by putting them behind feature flags/switches.

The idea

Abstracting your application functionality into small chunks and implementing them as loosely coupled directives. This allows you to completely remove sections of your application by simply toggling a single dom element.

How it works

The basic premise is you write your feature and wrap it up in a directive, then where you implement that directive in your markup you add the feature-flag directive to the same element. You can then pass the key of the flag to this directive to resolve whether of not this feature should be enabled.

The module pulls a json file down which defines the feature flags and which ones are active. If enabled angular will process the directive as normal, if disabled angular will remove the element from the dom.

You can then add the override panel to your app and turn individual features on override the server values, saving the override in local storage which is useful in development.

Flag data

The flag data that drives the feature flag service is a json format. Below is an example:

[
    { "key": "...", "active": "...", "name": "...", "description": "..." },
    ...
]
key Unique key that is used from the markup to resolve whether a flag is active or not.
active Boolean value for enabling/disabling the feature
name A short name of the flag (only visible in the list of flags)
description A long description of the flag to further explain the feature being toggled (only visible in the list of flags)

Setting flag data

Flag data can be set via the flags service using the set method. This currently accepts either an HttpPromise or a regular Promise. The promise must resolve to a valid collection of (flag data)[#flag-data].

For example, if you were loading your flag data from a remote JSON file:

myApp.run(function(flags, $http) {
  flags.set($http.get('/data/flags.json'));
});

Running the demo

Running the demo is easy assuming you have Gulp installed:

  • Checkout the project
  • Switch to the directory
  • Run 'gulp demo'

Should launch the demo in your default browser

Running the unit test

This relies on Gulp also obviously, to run the test suite:

  • Checkout the project
  • Switch to the directory
  • Run 'gulp test'

About

An AngularJS module that can be used to hide/exclude application features until they are ready.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 95.2%
  • CSS 4.8%