ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
46 lines (37 loc) • 826 B
Markdown
title:
zh-CN: 基础样例
en-US: Basic Usage
order: 0
## zh-CN
最简单的用法。
## en-US
Simplest of usage.
```ts
import { Component } from '@angular/core';
import { SFSchema } from '@ohayo/form';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-demo',
template: `<sf [schema]="schema" (formSubmit)="submit($event)"></sf>`,
})
export class DemoComponent {
schema: SFSchema = {
properties: {
name: { type: 'string' },
age: { type: 'number' },
},
required: ['name', 'age'],
ui: {
// 指定 `label` 和 `control` 在一行中各占栅格数
spanLabel: 4,
spanControl: 5,
},
};
constructor(private msg: NzMessageService) {}
submit(value: {}): void {
this.msg.success(JSON.stringify(value));
}
}
```