nz-switch-value
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published

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>

Package Sidebar

Install

npm i nz-switch-value

Weekly Downloads

2

Version

0.0.2

License

MIT

Unpacked Size

7.09 kB

Total Files

4

Last publish

Collaborators

  • chaimzhang