如何使儿童参数角5

时间:2018-10-17 18:46:30

标签: angular angular5 router

在我的应用程序中,路由是这样的:

Object (fromList [("ABC", String "123")])

我尝试过:

1:

{
  path: 'routeA/:paramA',
  component: ComponentA,
  children: [
    {
      path: 'routeB/:paramB',
      component: ChildComponentB,
      children: [
        {
          path: 'routeC/:paramC',
          component: ChildComponentC
        }
      ]
    }
  ]
},

2:

const param = this.route.paramMap.subscribe(( params: ParamMap ) : void => {

  console.info(params)

2 个答案:

答案 0 :(得分:2)

对于组分A,

import {Router, ActivatedRoute} from '@angular/router';
@Component({
  selector: 'app-component-a',
  templateUrl: './component-a.component.html',
  styleUrls: ['./component-a.component.scss'],
});
export class ComponentA {
  paramA: any;
  constructor( private route: ActivatedRoute) {
     this.paramA = this.route.snapshot.queryParams['paramA'];
     // Or you can try this one also
     this.route.params.subscribe(res => this.paramA = res.paramA);
  }
}

答案 1 :(得分:1)

library(tidyverse) dat <- data.frame(age=c(50,55,60,50,55),sex=c(1,1,1,0,1),bmi=c(20,25,30,20,25)) dat %>% group_by_all() %>% summarise(count = n()) %>% arrange(desc(count)) #> # A tibble: 4 x 4 #> # Groups: age, sex [4] #> age sex bmi count #> <dbl> <dbl> <dbl> <int> #> 1 55 1 25 2 #> 2 50 0 20 1 #> 3 50 1 20 1 #> 4 60 1 30 1 中注入ChildComponentC作为依赖项:

ActivatedRoute

然后在constructor(private route: ActivatedRoute) {} 中使用此:

ngOnInit