订阅 ActivatedRoute 的参数时,出现错误Cannot find name 'Params'。我从哪个包导入它?
import { Component, OnInit } from '@angular/core';
import { Recipe } from '../recipe.model';
import { RecipeService } from '../../services/recipe/recipe.service';
import { ActivatedRoute } from '@angular/router';
Run Code Online (Sandbox Code Playgroud)
// 我这里缺少一个导入。只是不知道从哪个包加载。
@Component({
selector: 'app-recipe-detail',
templateUrl: './recipe-detail.component.html',
styleUrls: ['./recipe-detail.component.css']
})
export class RecipeDetailComponent implements OnInit {
recipe: Recipe;
id: number;
constructor (
private rService: RecipeService ,
private ACTIVATED_ROUTE: ActivatedRoute,
) {
}
ngOnInit() {
const id = this.ACTIVATED_ROUTE.snapshot.params['id'];
this.ACTIVATED_ROUTE.params.subscribe(
( P: Params ) => { // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< …Run Code Online (Sandbox Code Playgroud)