恢复状态值
import { Router,NavigationExtras } from '@angular/router';
constructor(private router: Router)
{
const navigation = this.router.getCurrentNavigation();
const state = navigation.extras.state as {example: string};
this.example = state.example;
}
路线导航
const navigationExtras: NavigationExtras = {state: {example: 'This is an example'}};
this.router.navigate(['/trace/geospatial'], navigationExtras);
获取以下问题
类型“ Router”上不存在属性“ getCurrentNavigation”,并且对象文字只能指定已知属性,并且类型“ NavigationExtras”中不存在“ state”