-
Notifications
You must be signed in to change notification settings - Fork 0
task#15 outlet and default
bacn edited this page Sep 16, 2020
·
1 revision
- Add the routerOutlet to the template of your AppComponent.
- Add an redirect to your book list of you open your app with an empty path.
Start the test-auction-api server in a second console with $ test-auction-api if not yet running.
Compile and start the application with
ng serve
Open project in browser
- Open your browser with the address http://localhost:4200/
- In the browser window shall appear: http://localhost:4200/auctions
It should automatically navigate to the Default route /auctions.
add:
<router-outlet></router-outlet>
delete or comment the existing app-auction-list.component selector
<h1>
{{title}} <i class="fa fa-check"></i>
</h1>
<button class="btn btn-primary">Test Button</button>
<router-outlet></router-outlet>Add the default route definition:
{
path: '',
pathMatch: 'full',
redirectTo: '/auctions'
}We want to forward a call to / to /auctions.
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import {AuctionListComponent} from './auction-list/auction-list.component';
const routes: Routes = [
{
path: '',
pathMatch: 'full',
redirectTo: '/auctions'
},
{
path: 'auctions',
component: AuctionListComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }