ng-flips
Angular module to use feature switches, configurable through environment variables, or api, packaged with Angular CLI version 6.0.3.
Usage
Install
$ npm install ng-flips --save
Import and configure
// ...
import { NgFlipsModule, NgFlipsComponent, FlipsConfig } from 'ng-flips';
import {environment} from '../environments/environment';
// ...
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
NgFlipsModule.forRoot(environment, <FlipsConfig>{json: {features: [{feature: "hello", switchedOn: true}]}})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
place the NgFlipsModule
in your modules imports array, and inject the environment setup, and Flips configuration to the forRoot
method.
Check the Angular guide how environments should work.
then in your template in any component:
<ng-flips [onFeature]="'hello'">
<p> Hi! </p>
<p fallback> Bye </p>
</ng-flips>
wrap your feature into an ng-flips
element give the flag name to the onFeature
attribute.
If you have the named feature enabled the child elements will show up, otherwise not.
If you specify any dom element with the fallback
attribute, that will work as an else statement.
Tip
Try to structure your app to separate modules so you can have more different configs not one big global one.