我们目前正在计划一个带有材料设计的新角度7应用程序(md-tabs),它可以与多个标签一起使用。基本上应该可以动态创建新选项卡,它应该代表路由的内容。在开始时,应在始终存在的第一个选项卡中打开起始页。通过某些操作,将使用路径创建新选项卡。
如果现在单击导航中的链接,则应始终在当前活动的选项卡中加载此内容。
要动态创建这些新选项卡,我使用数组,这不是问题。如何在新选项卡中动态加载路由以及如何将路由器出口动态地重定向到另一个选项卡对我来说是一个谜。有没有人知道是否以及如何做到这一点?
这是我的例子:
import { Component, OnInit } from '@angular/core';
import { ChService } from '../../services/ch.service';
import { Router } from '@angular/router';
@Component({
selector: 'app-dashboard',
templateUrl: 'login.component.html'
})
export class LoginComponent implements OnInit {
pb: boolean = false;
ngOnInit() {
if (this.ch.getLocalUser()) {
this.ch.token = this.ch.getLocalUser().auth_key;
this.router.navigate(['/crm/myorders'])
}
}
constructor(public ch: ChService, private router: Router) { }
login() {
this.ch.last_err = '';
this.ch.getAuthtoken();
}
}
我通过这个字符串导航到路线:
this.router.navigate(['/crm/myorders'])
祝好运!