By default HeaderComponent contains "userMenu = [{ title: 'Profile'}, { title: 'Log out'}];", how to add a click event to Log out to call function from Component? I tried to itemClick(event, item) and menuClick(event, item) as I found in Documentation (https://akveo.github.io/nebular/#/docs/components/user-avatar) but none of them works.
Hey @jogamod would you mind sharing your code? As <user (menuClick)="onMenuClick($even)"> should work.
I meet to so problem, How to do? maybe have code example?
is error
How to setting?
@YukiDmZhao what errors are you getting?
onMenuClick($even){
console.log('$even======>',$even);
}
$even======> undefined
can not run I want to function
@YukiDmZhao it should be $event with t and the end in your template.
@nnixaa I have a doubt.
I'm trying to add a function to the logout option.
userMenu = [
{ title: 'Profile' },
{ title: 'Log out', click: console.log('/login') }
];
But this runs when the class is instantiated.
You know how I can solve this?
@miguelleitevieira
you can do this :
userMenu = [
{ title: 'Profile' },
{ title: 'Log out', link: '/logout' }
];
@sKaouech very good tick...
I used of routerlink into logout function that has a problem and redirected to login page.
logOut() {
this.authService.logout('email')
this.router.navigate(['/auth/logout']);
}
@nnixaa Why past my solution has a problem?
Most helpful comment
@miguelleitevieira
you can do this :
userMenu = [
{ title: 'Profile' },
{ title: 'Log out', link: '/logout' }
];