ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
85 lines (73 loc) • 1.6 kB
text/typescript
import {Component, OnInit} from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
const init_options = [{
value: 'zhejiang',
label: 'Zhejiang',
children: [{
value: 'hangzhou',
label: 'Hangzhou',
children: [{
value: 'xihu',
label: 'West Lake',
isLeaf: true
}],
}, {
value: 'ningbo',
label: 'Ningbo',
isLeaf: true
}],
}, {
value: 'jiangsu',
label: 'Jiangsu',
children: [{
value: 'nanjing',
label: 'Nanjing',
children: [{
value: 'zhonghuamen',
label: 'Zhong Hua Men',
isLeaf: true
}],
}],
}];
export class NzDemoCascaderReactiveFormComponent implements OnInit {
/** init data */
_options = null;
_value: any[] = null;
_form: FormGroup;
_console(value) {
console.log(value);
}
constructor(private _fb: FormBuilder) {
this._createForm();
}
ngOnInit() {
this._options = init_options;
}
_createForm() {
this._form = this._fb.group({
name: [null, Validators.required ]
});
}
_reset(): void {
this._form.reset();
}
}