Angular多路由出口配置

本文介绍了在Angular中设置多路由出口的思路和步骤,包括在`app-routing.module.ts`中配置路由对象的`outlet`属性,以及在模板中使用指定`name`属性的`router-outlet`,确保两者匹配实现多路由出口的功能。
摘要由CSDN通过智能技术生成

1、大体思路

主要通过指定router-outlet的name属性,并在路由配置文件中指定路由对象的outlet属性,router-outlet
的name属性和路由对象的outlet属性的值保持一致即可。

2、app-routing.module.ts的代码

import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { Test00Component } from './component/test00/test00.component';
import { Test01Component } from './component/test01/test01.component';
import { Test02Component } from './component/test02/test02.component';

const routes: Routes = [
  {
    path: '',
    component: Test00Component
  },
  {
    path: 'test00',
    component: Test00Component
  },
  {
    path: '',
    component: Test01Component,
    outlet: 'test'
  },
  {
    path: 'test01',
    component: Test01Component,
    outlet: 'test'
  },
  {
    path: 'test02',
    component: Test02C
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值