Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
ngx-feature-toggle
Advanced tools
Your module to handle with feature toggles in Angular applications easier.
Your module to handle with feature toggles in Angular applications easier.
This is a common concept, but why use this directive instead solve it via server-side rendering?
The idea of this directive is make this process transparent and easier. So the main point is integrate this directive with other tooling process, such as:
You can integrate with WebSockets or handling this in a EventSourcing architecture. It's totally transparent for you and you can integrate easier in your application.
Try out the demo!
You can get it on NPM installing ngx-feature-toggle
module as a project dependency.
npm install ngx-feature-toggle --save
You'll need to add FeatureToggleModule
to your application module. So that, the featureToggle
directive will be accessible in your application.
@NgModule({
declarations: [
YourAppComponent
],
imports: [
FeatureToggleModule,
...
],
providers: [],
bootstrap: [YourAppComponent]
})
export class YourAppComponent {}
Now you just need to add a configuration in your application root component. Your feature toggle configuration can be added using different approaches, such as:
After that, you can use the featureToggle
directive in your templates, passing the string based on the feature toggle configuration data.
import { Component } from '@angular/core';
import { FeatureToggleServiceProvider } from 'ngx-feature-toggle';
@Component({
selector: 'component-docs',
template: `
<h3>Live code</h3>
<p>Feature Toggle Configuration Data: </p>
<p><b>{{ featureToggleData | json }}</b></p>
<feature-toggle [featureName]="'enableSecondText'">
<p>condition is true and "featureToggle" is enabled.</p>
<feature-toggle [featureName]="'enableFirstText'">
<p>condition is false and "featureToggle" is disabled. In that case this content should not be rendered.</p>
</feature-toggle>
<feature-toggle [featureName]="'enableFirstText'" showWhenDisabled >
<p>condition is false and "featureToggle" is disabled and it has "showWhenDisabled" attribute.</p>
<p>In that case this content should be rendered.</p>
</feature-toggle>
</feature-toggle>
`
})
export class ComponentDocsComponent {
public featureToggleData: any = {
enableFirstText: false,
enableSecondText: true
};
}
Run demo locally:
npm run build
(npm run build-watch
to run build in watch mode)npm run link
npm start
Publish
Update demo (gh-pages)
Wilson Mendes (willmendesneto)
[3.0.0][] - 2021-07-23
forRoot()
more than once if module is loaded asynchronously in a submodule. This is required in order to avoid issues in consumers. To avoid that, consumers should load the module once on the main module instead - if loading submodules async.FAQs
Your module to handle with feature toggles in Angular applications easier.
The npm package ngx-feature-toggle receives a total of 5,805 weekly downloads. As such, ngx-feature-toggle popularity was classified as popular.
We found that ngx-feature-toggle demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.