ng-ytl-zorro-antd
Version:
An enterprise-class UI components based on Ant Design and Angular
110 lines (100 loc) • 2.11 kB
text/typescript
import {Component, OnInit} from '@angular/core';
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
}],
}],
}];
const other_options = [{
value: 'fujian',
label: 'Fujian',
children: [{
value: 'xiamen',
label: 'Xiamen',
children: [{
value: 'Kulangsu',
label: 'Kulangsu',
isLeaf: true
}],
}],
}, {
value: 'guangxi',
label: 'Guangxi',
children: [{
value: 'guilin',
label: 'Guilin',
children: [{
value: 'Lijiang',
label: 'Li Jiang River',
isLeaf: true
}],
}],
}];
export class NzDemoCascaderBasicComponent implements OnInit {
/** init data */
_options = null;
_value: any[] = null;
_console(value) {
console.log(value);
}
ngOnInit() {
// let's set nzOptions in a asynchronous way
setTimeout(() => {
this._options = init_options;
}, 100);
}
_changeNzOptions(): void {
if (this._options === init_options) {
this._options = other_options;
} else {
this._options = init_options;
}
}
}