我需要帮助来添加到角树的路线。
HTML 代码:
<mat-tree [dataSource]="dataSource" class="tree-container" [treeControl]="treeControl">
<mat-tree-node class="btnLinks" *matTreeNodeDef="let node" matTreeNodePadding>
<button mat-icon-button disabled></button>
{{node.name}}
</mat-tree-node>
<mat-tree-node class="btnLinks" *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding>
<button mat-icon-button matTreeNodeToggle
[attr.aria-label]="'toggle ' + node.name">
<mat-icon class="mat-icon-rtl-mirror">
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}}
</mat-icon>
</button>
{{node.name}}
</mat-tree-node>
</mat-tree>
.ts 文件
interface ProfileList {
name: string;
children?: ProfileList[];
}
const PROFILE_DATA: ProfileList[] = [
{
name: 'General',
},
{
name: 'Degrees',
},
];
/** Flat node with expandable and level information */
interface TreeFlatNode {
expandable: boolean;
name: string;
level: number;
}
@Component({
selector: 'mpn-profile-landing',
templateUrl: './profile-landing.component.html',
styleUrls: ['./profile-landing.component.css']
})
export class ProfileLandingComponent {
public selectedItem : String = '';
constructor(private breakpointObserver: BreakpointObserver) {
this.dataSource.data = PROFILE_DATA;
}
private transformer = (node: ProfileList, level: number) => {
return {
expandable: !!node.children && node.children.length > 0,
name: node.name,
level: level,
};
}
我需要添加路由,比如当我点击度数时,我需要导航到另一个页面,我不确定在哪里放置路由器链接。是否有可能做到这一点?谢谢你。