添加菜单页路由
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { Component, OnInit,Input } from '@angular/core';
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { Router } from '@angular/router'
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar-menu',
|
||||
@@ -9,7 +10,9 @@ export class SidebarMenuComponent implements OnInit {
|
||||
//输入数据
|
||||
@Input() data: Array<any>;
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private router: Router
|
||||
) { }
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
@@ -30,6 +33,8 @@ export class SidebarMenuComponent implements OnInit {
|
||||
itemClicked(item: any) {
|
||||
if (!this.isLeaf(item)) {
|
||||
item.isExpend = !item.isExpend;
|
||||
} else {
|
||||
this.router.navigate([item.path])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user