简体   繁体   中英

can't redirect to profil url in angular5

working with a simple app in angular5 , i have a header containing 'profil' link , i'm trying to redirect the user to the profilComponent when clicking on the link but nothing happends , instead of that the user get logged out of the app .

i'm Using jwt for authentication .

This is how the structure of the project looks like :

在此处输入图片说明

for profil components it exists inside views directory :

在此处输入图片说明

i have already added ProfilRoutingModule in the profil module , and also i have added profil module in app.routing.ts :

{
    path: 'profil',
    loadChildren: './views/profil/profil.module#ProfilModule'
  },

do i miss something ? Why i cant be redirected to profil and getting logged out of the app instead? Any idea?

Why use href? Angular has routerlink. Use it like this.

routerLink="/profile"

您需要设置routerLink而不是href

  <li><a [routerLink]="['/profil']">Profil</a></li>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM