git clone git@github.com:len007/my-angular2-app.git my-angular2-app

开始

一个URL = 一个页面 = 一个Component。

我们可以使用路由来实现页面之间的切换与导航。

使用路由前,我们先安装router包:

npm --save-dev install router

首先,我们建立个根路由,app-router.module.ts

import { Routes } from '@angular/router';

export const AppRouterModule: Routes =[
    {
        path: '',
        loadChildren: 'app/home/home.module#HomeModule'
    },
    {
        path: 'list',
        loadChildren: 'app/list/list.module#ListModule'
    },
    {
        path:'**',
        loadChildren: 'app/home/home.module#HomeModule'
    }
];

这是最简单的路由配置

 

posted on 2018-04-24 00:19  Failbs  阅读(239)  评论(2编辑  收藏  举报