活动链接 选择星云作为角度



我在我的 angular front 应用程序中使用 nebular,并且想设置选定的活动链接。 我怎样才能实现它?

我已经尝试使用菜单项的选定属性,但它仅适用于项目对象,并且没有 [routerLinkActive] 选项

@Component({
  selector: 'nebular-pages',
  styleUrls: ['nebular.component.scss'],
  template: `
    <ngx-sample-layout>
      <nb-menu [items]="menu"></nb-menu>
      <router-outlet></router-outlet>
    </ngx-sample-layout>
  `,
})
export class NebularComponent {
  menu: NbMenuItem[];
  constructor() { }
        this.menu = [
          {
            title: 'Page1',
            link: `/user/params`,
            icon: 'nb-grid-b-outline',
            home: true,
          },
          {
            title: 'Page2',
            link: '/user/options',
            icon: 'nb-arrow-thin-right',
          },
          {
            title: 'Page3',
            icon: 'nb-list',
            children:[
              {
                title: 'Costs',
                link: '/user/costs',
                icon: 'nb-arrow-thin-right',
              },
              {
                title: "Benifits",
                link: "/user/benifits",
                icon: "nb-compose"
              },
            ]
          },
        ];

尝试将 pathMatch:'full' 添加到菜单项

items: NbMenuItem[] = [
    {
      title: 'Login',
      icon: 'person-outline',
      link: '/login',
      pathMatch:'full'
    },
    {
      title: 'Register',
      icon: 'lock-outline',
      link: '/register',
      pathMatch:'full'
    },
    {
      title: 'Logout',
      icon: 'unlock-outline',
      link: '/logout',
      pathMatch:'full'
    },
  ];

最新更新