I just want to test the click event in div element and it doesnt works
So here is the part of code in html and ts files :
HTML:
<div class="col-md-3 mx-auto d-flex flex-row justify-content-center align-items-center"
style="height: 200px; background-color: rgba(100, 100, 179, 0.1); position: relative;"
(click)="goToInvoices()"
>
<h2>Invoices</h2>
</div>
TS :
// i've tried to add also :any for return type
goToInvoices() {
this.router.navigate(['/invoices']).then(nav => {
console.log(nav); // true if navigation is successful
}, err => {
console.log(err) // when there's an error
});
}
In console nav is null !!!
app.module.ts:
const routes: Routes = [
{path: '', redirectTo: 'home', pathMatch: 'full'},
{path: '**', redirectTo: 'home', pathMatch: 'full'},
{path: 'invoices', component: InvoicesComponent},
];
Angular version : 9.1.7
RouterModuleinside the component's module ?router-outletmissing. this is where the routed content get rendered. Check stackBlitz below