I'm trying to link a component from one component using routerLink = "selected"
const routes: Routes = [
{
path: '',
children: [
{
path: 'account',
component: AccountComponent,
children: [
{
path: 'selected',
component: SelectedComponent,
},
],
},
]
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule],
})
export class AccountSettingsRoutingModule { }
This is AccountComponent
import { Component, OnInit, AfterViewInit } from '@angular/core';
import { Router, ActivatedRoute, RouterModule } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Http, Response, Headers } from '@angular/http';
@Component({
selector: 'app-list-accounts',
templateUrl: './accounts-list.component.html',
styleUrls: ['./accounts-list.component.scss']
})
export class AccountComponent implements OnInit {
constructor(private http: HttpClient, private router: Router) { }
ngOnInit() {}
}
The url is changing to the desired like this dashboard/account/selected, but the view is not loading.
Add <router-outlet></router-outlet>
to AccountComponent. Read more in the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With