- Hands-On Full Stack Web Development with Angular 6 and Laravel 5
- Fernando Monteiro
- 142字
- 2021-07-23 19:18:55
Adding a new route
As you saw previously, routes are part of every web application. Now, we will add a new route, so that we can access the content of our beers module. Open src/app/app-routing.module.ts and replace the code with the following:
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { AppComponent } from './app.component';
import { BeersComponent } from './beers/beers.component';
const routes: Routes = [
{ path: '', redirectTo: 'beers', pathMatch: 'full' },
{ path: 'beers', component: BeersComponent }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Note that we are just adding the new route to an existing route file (in this case, app.routing.module.ts), as this example is extremely simple. But, in larger applications, it is recommended that you create individual route files for each application module.
推薦閱讀
- Application Development with Qt Creator(Second Edition)
- RCNP實(shí)驗(yàn)指南:構(gòu)建高級的路由互聯(lián)網(wǎng)絡(luò)(BARI)
- 面向物聯(lián)網(wǎng)的CC2530與傳感器應(yīng)用開發(fā)
- 重新定義Spring Cloud實(shí)戰(zhàn)
- Learning Karaf Cellar
- Spring Cloud微服務(wù)架構(gòu)進(jìn)階
- 通信簡史:從信鴿到6G+
- Socket.IO Real-time Web Application Development
- 電力物聯(lián)網(wǎng)工程技術(shù)原理與應(yīng)用
- SAE原理與網(wǎng)絡(luò)規(guī)劃
- Getting Started with nopCommerce
- 想象的互動:網(wǎng)絡(luò)人際傳播中的印象形成
- 趣話通信:6G的前世、今生和未來
- OpenShift Cookbook
- Hands-On Full Stack Web Development with Aurelia