我正在尝试做一个返回用户的简单Resolve.但是,在我的应用程序中,我需要使用自己的类包装http组件,该类将Subject作为observable返回. 我的解析器在第一个用户链接上按预期工作,但在Resolve之后单击UserProfileComponent中的任何用户链接时,Resolve永远不会再次完成. 我可以看到浏览器URL使用新ID更改,并且UserResolve中的console.log打印,但没有任何反应.
我的路由器:
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from './dashboard/dashboard.component';
import { UserProfileComponent } from './user-profile/user-profile.component';
import { LoginComponent } from './login/login.component';
import { AuthGuard } from './_resolve/guard.auth';
import { UserResolve } from './_resolve/user.resolve';
const appRoutes: Routes = [
{ path: '', component: DashboardComponent, canActivate: [AuthGuard] },
{ path: 'user/:id', component: UserProfileComponent, canActivate: [AuthGuard], resolve: { user: UserResolve } },
{ path: 'login', component: LoginComponent },
// otherwise redirect to home
{ path: …Run Code Online (Sandbox Code Playgroud)