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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ng-feature-toggle

v1.0.4

Published

Feature Toggle module for Angular JS

Downloads

25

Readme

angular-feature-toggle

Build Status

An AngularJS module that allows you to control when you release new features in your app or use it on the users authorization by putting them behind feature toggle/switches. This module should work with angular 1.2 and up, but has only been tested on Angular v1.5 and up.

The idea

Abstracting your application functionality into small chunks and implementing them as loosely coupled components. This allows you to completely remove pages, actions or elements of your application by simply toggle them.

How it works

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

The module pulls a json file down which defines the feature toggle and which ones are active.

  • 'ON': Angular will process the directive as normal.
  • 'DISABLED': Angular will tag the element as disabled and add a 'disabled' class.
  • 'OFF': Angular will remove the element from the dom and not compile or execute any other directives is has.

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.

Install

npm install --save ng-feature-toggle

flag data

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

[
    { "name": "...", "status": "..." },
    ...
]

Setting flag data on config phase

You can also initialize the feature flags in the config phase of your application:

import 'ng-feature-toggle';

var myApp = angular.module('app', ['featureToggle']);

myApp.config(function(featureToggleProvider) {
  featureToggleProvider.setFeatures([
          {name: 'test', status: 'off'},
          {name: 'supertest', status: 'on'},
          {name: 'disabledtest', status: 'disabled'}
  ]);
});

Setting flag data in controller

Flag data can be set via the featureToggle service using the set method.

var myApp = angular.module('app', ['featureToggle']);

default class MyAppController {
	// featureToggle service inject
	constructor (featureToggle) {
 		featureToggle.setFeatures([
          {name: 'test', status: 'off'},
          {name: 'supertest', status: 'on'},
          {name: 'disabledtest', status: 'disabled'}
  		]);
	}
}

Toggling elements

The feature-toggle directive allows simple toggling of elements based on feature flags, e.g:

 <input feature-toggle="myTag">
 	I will be visible if 'myTag' is enabled
 </input>