import { Component, OnInit, Input, Output, EventEmitter } 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 }], }], }]; @Component({ selector: 'cm-cascader-doc-1', templateUrl: './cascader-doc-1.component.html', styleUrls: ['./cascader-doc-1.component.css'] }) export class CascaderDoc1Component implements OnInit{ _options:any = null; _value: any[] = null; _console(value:any) { console.log(value); } constructor() {} 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; } } }