- 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.
推薦閱讀
- 計(jì)算機(jī)網(wǎng)絡(luò)與通信(第2版)
- 網(wǎng)絡(luò)安全技術(shù)與解決方案(修訂版)
- 物聯(lián)網(wǎng)與無線傳感器網(wǎng)絡(luò)
- 網(wǎng)管員必讀:網(wǎng)絡(luò)管理(第2版)
- OMNeT++與網(wǎng)絡(luò)仿真
- 光纖通信系統(tǒng)與網(wǎng)絡(luò)(修訂版)
- 4G小基站系統(tǒng)原理、組網(wǎng)及應(yīng)用
- 局域網(wǎng)組成實(shí)踐
- 精通SEO:100%網(wǎng)站流量提升密碼
- 區(qū)塊鏈社區(qū)運(yùn)營(yíng)手冊(cè)
- Cisco無線局域網(wǎng)配置基礎(chǔ)
- 智慧的物聯(lián)網(wǎng):感知中國(guó)和世界的技術(shù)
- 路由與交換技術(shù)
- CDN技術(shù)詳解
- 網(wǎng)絡(luò)設(shè)備配置與調(diào)試項(xiàng)目實(shí)訓(xùn)