Getting Started
This directive library helps you to set the value of ngTrue and ngFalse for HTML Form checkbox element in angular other than boolean value(true|false). It is simply an alternative to the ng-true-value and ng-false-value in angular 2+.
Authors
Installation
Install @nikiphoros/ngx-toggle with npm
npm install @nikiphoros/ngx-toggle
Add needed package to NgModule imports:
import { NgxToggleModule } from '@nikiphoros/ngx-toggle';
@NgModule({
...
imports: [NgxToggleModule,...]
...
})
Uses
existing behavior which only return only boolean (true|false)
<input id="status" type="checkbox" name="status" [(ngModel)]="status">
<label for="status">result {{status}}</label>
add ToggleValue directive and custom value for true & false which you want to set as below,
<input id="switch" type="checkbox" name="switch" [(ngModel)]="switch" ToggleValue [true]="'on'" [false]="'off'">
<label for="status"> result {{switch}}</label>