Text

Text in form.

Rules

  • Forced remove of the required effect

  • Auto render - if the defaultText value does not exist

Examples

Basic Usage

Simplest of usage.

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

@Component({
  selector: 'form-text-simple',
  template: ` <sf [schema]="schema" [loading]="loading" (formSubmit)="submit($event)"></sf> `,
})
export class FormTextSimpleComponent {
  loading = false;
  schema: SFSchema = {
    properties: {
      id1: { type: 'number', ui: { widget: 'text' } as SFTextWidgetSchema },
      id2: { type: 'number', ui: { widget: 'text', defaultText: 'default text' } as SFTextWidgetSchema },
      name: {
        type: 'string',
        title: 'Name',
        ui: {
          addOnAfter: 'RMB',
          placeholder: 'RMB结算',
        } as SFStringWidgetSchema,
      },
    },
    required: ['name'],
  };

  constructor(private msg: NzMessageService) {}

  submit(value: {}): void {
    this.loading = true;
    setTimeout(() => {
      this.loading = false;
      this.msg.success(JSON.stringify(value));
    }, 1000);
  }
}

API

ui

PropertyDescriptionTypeDefault
[defaultText]Default text of this itemstring-
[html]Whether to support HTMLbooleantrue