Open web-dave opened 2 years ago
(Pro Nav-Link eine)
ng g component swapi/films
src
Angular Generator
Component
films
src/app/swapi
SwapiModule
declarations
swapi-routing.module.ts
SwapiRputingModule im SwapiModule in das
app-routing.module.ts
/films
In der Navigation die href in routerLink="" ändern
href
routerLink=""
import { NgModule } from '@angular/core'; import { RouterModule, Routes } from '@angular/router'; import { FilmsComponent } from './films/films.component'; const routes: Routes = [ { path: 'films', component: FilmsComponent, }, { path: 'people', component: PeopleComponent, }, { path: 'planets', component: PlanetsComponent, }, { path: 'species', component: SpeciesComponent, }, { path: 'starships', component: StarshipsComponent, }, { path: 'vehicles', component: VehiclesComponent, }, ]; @NgModule({ imports: [RouterModule.forChild(routes)], exports: [RouterModule] }) export class SwapiRoutingModule { }
Next
Generiere 6 neue Angular Components.
(Pro Nav-Link eine)
Lokal
Online
src
Ordner in der Projekt Section.Angular Generator
Component
auswählenfilms
im Promt eingeben und bestätigensrc/app/swapi
verschiebenSwapiModule
indeclarations
array eintragenRouting
swapi-routing.module.ts
untersrc/app/swapi
anlegenSwapiRputingModule im SwapiModule in das
imports` array eintragenapp-routing.module.ts
redirect auf/films
eintragenIn der Navigation die
href
inrouterLink=""
ändernSwapiRoutingModule
swapi-routing.module.ts
SwapiModule
## swapi.module.ts ```ts @NgModule({ declarations: [], imports: [ CommonModule, HttpClientModule, SwapiRoutingModule ] }) export class SwapiModule { } ```AppRoutingModule
## app-routing.module.ts ```ts const routes: Routes = [ { path: '', redirectTo: '/films', pathMatch: 'full', }, ]; ```TopNav
## top-nav.vomponent.html ```html films ```