2017-08-01 189 views
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創建標籤甚至沒有提到;檢查源代碼也沒有揭示這樣的功能。

回答

相關問題