1
我正在使用材料选项卡,解释如下here。我很难找出如何以编程方式创建(然后专注于)新选项卡。我还想在不再需要时删除标签。通过在网上挖我开始猜测一些函数调用像以编程方式创建选项卡
export class VehiclesComponent {
@ViewChild(MdTabsModule) tabs: MdTabsModule;
constructor (private router: Router, private parentComponent: AdminComponent, private userService: VehicleService) {}
ngOnInit() {
/* code presented here for demonstration purposes */
this.tabs.push({label: "Some new tab", content: '<b>New tab content</b>'});
}
}
当然这个代码是完全是编造的,它不工作。至少现在我知道MdTabsModule没有名为push的方法。不幸的是文件非常恐慌。通过TypeScript创建标签甚至没有提到;检查源代码也没有揭示这样的功能。