Switch

Switching Selector.

Examples

Basic Usage

Simplest of usage.

expand codeexpand code
import { Component } from '@angular/core';
import { SFSchema } from '@delon/form';
import { NzMessageService } from 'ng-zorro-antd/message';

@Component({
  selector: 'form-boolean-simple',
  template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
})
export class FormBooleanSimpleComponent {
  schema: SFSchema = {
    properties: {
      status: {
        type: 'boolean',
        title: '是否启用',
      },
      // 指定内容文本
      enabled: {
        type: 'boolean',
        title: '是否启用',
        ui: {
          checkedChildren: '开',
          unCheckedChildren: '关',
        },
      },
    },
  };

  constructor(private msg: NzMessageService) {}

  submit(value: {}): void {
    this.msg.success(JSON.stringify(value));
  }
}

API

schema

PropertyDescriptionTypeDefault
[readOnly]Whether to disable the stateboolean-

ui

PropertyDescriptionTypeDefault
[size]Size of the nz-switchdefault,smalldefault
[checkedChildren]Content to be shown when the state is checkedstring-
[unCheckedChildren]Content to be shown when the state is uncheckedstring-