angular routing



app.module.ts
   --> 하위 모듈 추가
   -->   예)

import { NgModule } from '@angular/core';
import { routing } from './app.routes';
import { ProjectModule } from './project/project.module'

@NgModule({
declarations: [
AppComponent,
],
imports: [
routing,
AlertModule.forRoot(),
ProjectModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }

app.routes.ts
  --> 안 넣어도 됨

/project
  project.routes.ts
import { RouterModule, Routes } from '@angular/router';
import { ListComponent } from './view/list/list.component';

const appRoutes: Routes = [
{ path: '', redirectTo: '/', pathMatch:'full' },
{ path: 'project', component: ListComponent }
];

export const routing = RouterModule.forRoot(appRoutes);

  project.module.tx
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ListComponent } from './view/list/list.component';
import { routing } from './project.routes';


@NgModule({
imports: [
CommonModule,
routing
],
declarations: [ListComponent]
})
export class ProjectModule { }

http://localhost:4200/project

댓글

이 블로그의 인기 게시물

한반도 왕 연대표-android app

가계부 for iphone 4.5 Update