Rate

A quick rating operation on something.

Examples

Basic Usage

Simplest of usage.

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

@Component({
  selector: 'form-rate-simple',
  template: ` <sf [schema]="schema" (formSubmit)="submit($event)"></sf> `,
})
export class FormRateSimpleComponent {
  schema: SFSchema = {
    properties: {
      rate: {
        type: 'number',
        title: '评级',
        default: 4.5,
        ui: {
          widget: 'rate',
        } as SFRateWidgetSchema,
      },
      // 允许半选
      rate2: {
        type: 'number',
        title: '评级',
        maximum: 5,
        multipleOf: 0.5,
        default: 4.5,
        ui: {
          widget: 'rate',
          text: '{{value}} starts',
        } as SFRateWidgetSchema,
      },
    },
  };

  constructor(private msg: NzMessageService) {}

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

API

schema

PropertyDescriptionTypeDefault
[maximum]star countnumber5
[multipleOf]0.5 indicates allow semi selectionnumber0.5

ui

PropertyDescriptionTypeDefault
[allowClear]whether to allow clear when click againbooleantrue
[autoFocus]get focus when component mountedbooleanfalse
[text]Reminder text template, {{value}} indicates the current valuestring-
[tooltips]Customize tooltip by each characterstring[][]