> create a new module of user && home with routing
```
ng g module module/user --routing
```
```
ng g module module/home--routing
```
>create component user && home
```
ng g component module/home
```
```
ng g component module/user
```
>Edit user-routeing , In order to initialize self component
~~~
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
//import user module to be routed Below
import { UserComponent } from './user.component';
const routes: Routes = [
{
path:"",component:UserComponent,//initlization component
}
];
@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class UserRoutingModule { }
~~~
>also user component,When we finish writing, we also need to modify the route in the root component.
>app-routing.module.ts
~~~
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
const routes: Routes = [
{
// path:"user",loadChildren:"./module/user/user.module#UserModule"
path:"user",loadChildren:()=>import("./module/user/user.module").then(mod=>mod.UserModule)
},
{
// path:"home",loadChildren:"./module/home/home.module#HomeModule"
path:"home",loadChildren:()=>import("./module/home/home.module").then(mod=>mod.HomeModule)
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
~~~
- 引言
- 安装angular9
- 入门
- 数据绑定
- 属性绑定
- 实体字符和转义
- html 模板运算
- css样式规范
- 数组与循环ngFor
- 条件ngIf
- 管道
- 事件执行
- 双向数据绑定mvvm
- todolist页面交互
- 公共服务层
- 数据持久化
- dom与ViewChild装饰器
- 父子组件传值
- 子父组件传值ViewChild
- 子父组件out装饰器
- 生命周期-挂/卸载
- es6语法io异步promise
- Rxjs异步数据流编程
- http_request
- axios异步数据
- 英雄route路由
- 动态route路由
- navigate route
- Parent child routing
- modularization
- lazyload