Active Link выбрал Nebular для Angular

Я использую nebular в своем приложении angular front и хочу выбрать активную ссылку. как я могу этого добиться?

Я пробовал использовать свойство selected для menuItem, но оно применяется только к объекту item, и нет опции [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"
              },
            ]
          },

        ];

person Alex    schedule 05.06.2019    source источник
comment
Вы пробовали routerLinkActive?   -  person Tony Ngo    schedule 05.06.2019
comment
@Alex вы нашли какое-нибудь решение   -  person chikka.anddev    schedule 27.12.2019


Ответы (1)


Попробуйте добавить 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'
    },
  ];
person Vamsi Ambati    schedule 07.06.2020