我有一个辅助导航,其中的数据需要根据路线进行更改。请找到下图。
所有需要显示在组件上的数据存储如下。
export const Items: SecondaryNavItems[] = [
{
icon: 'far fa-copy', title: 'Newly Added Processes'
},
{
icon: 'far fa-copy', title: 'Terminated Processes'
},
{
icon: 'far fa-copy', title: 'Test Processes'
},
{
icon: 'far fa-copy', title: 'Test Processes'
}
];
这是 component.ts 文件。
export class SecondaryNavigationComponent implements OnInit {
public navItems: any[];
constructor() { }
ngOnInit() {
this.navItems = Items.filter(navItem => navItem);
}
}
有人能告诉我实现此目标的最佳方法吗?
最佳答案
为了让它在同一组件中工作,您可以使用订阅,以便在路由更改时触发,如下所示:
ngOnInit() {
this.route.paramMap.subscribe(params => {
this.animal = params.get("animal")
})
}
https://stackoverflow.com/questions/62630471/
相关文章:
php - 如何在 Ubuntu 16.04 中安装 php-curl
r - 控制 geom_line() 图表中的日期(x 轴)间隔
python - 如何从不同的文件调用方法而不在python中导入它
node.js - stripe.customers.retrieve 导致问题,因为它现在正在返回
python - 如何在 Tkinter 窗口上使用 for 循环创建多个框架?
flutter - 如何解决 PlatformException (PlatformExceptio
node.js - 错误 : getaddrinfo ENOTFOUND with docker-c