0.0.2 • Published 3 years ago

nz-switch-value v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

NZ-SWITCH-VALUE

An Angular directive for customizing the binding value of nz-switch.

npm NPM npm npm bundle size

English | 简体中文

Environment Support

  • Angular >=8
  • ng-zorro-antd >=8

Installation

  • npm
$ npm install nz-switch-value
  • yarn
$ yarn add nz-switch-value

Usage

API

参数说明类型默认值
[(switchValue)]双向绑定自定义值any----
[truthValue]自定义真值any'1'
[falseValue]自定义假值any'0'
(switchValueChange)开关状态变化时的回调EventEmitter<any>----

Example

Import the directive modules you want to use into your app.module.ts file.

import {NzSwitchValueModule} from 'nz-switch-value';

@NgModule({
  imports: [
    NzSwitchValueModule
  ]
})
export class AppModule {
}
export class WelcomeComponent {
  val = 0;

  onSwitchChange(val: any) {
    console.log(val);
  }
}
<nz-switch [ngModel]="val==1"
           [(switchValue)]="val"
           [truthValue]="1"
           [falseValue]="0"
           (switchValueChange)="onSwitchChange($event)">
</nz-switch>