Inside my code, I used routerLink to redirect the user if he's not authenticated and works perfectly, but in the same page I have couple links that redirect to the suggested post but on click, only the link in the browser changes and the clicked post does not load, here is my current version of the code:
Note: RouterModule already Import in app.module.ts
import { RouterModule } from '@angular/router';
@NgModule({
declarations: [
...
FaqComponent,
],
imports: [
RouterModule,
BrowserModule,
...
],
providers: [],
bootstrap: []
})
export class AppModule { }
Not working:
<h1>Suggested FAQ</h1>
<ul class="list-group list-group-flush">
<li style="padding: 12px 0px;background-color: transparent;font-weight: bold;" *ngFor="let faq of suggestedFaqs" class="list-group-item">
<a routerLink="/faq/{{faq.id}}/{{faq.title}}" >{{faq.title}}</a>
</li>
</ul>
Works:
<div style="margin: 30px 0px;" *ngIf="!isLoggedIn">
<a routerLink="/login" class="btn_faq" >login</a>
</div>
Path definition in app-routing.module.ts
{ path: 'faq/:id/:title', component: FaqComponent},
Example:
http://localhost:4200/faq/2/Changer%20votre%20langue%20préférée.
The route works perfectly when it's clicked outside the FaqComponent but if it's Clicked inside the FaqComponent it doesnt work