“我的选择”组件有两种用途:
use-my-select.html模板
动态创建。
它在模板中有效,但不能动态创建。
如何动态创建my-select组件,以便调用mySelected()?
my-select.ts
@Component({
selector: 'my-select',
templateUrl: './my-select.html'
})
export class MYSelect {
@Output() mySelected: EventEmitter<string> = new EventEmitter();
}
use-my-select.html
<my-select (mySelected)="mySelected($event)" ></my-select>
use-my-selct.ts
@ViewChild('select') select: MYSelect;
Object.assign(this.select, { mySelected: "mySelected()" });
mySelected(option) {
}