我试图从URL无法从路径URL
@Component({
templateUrl: './confirm-registration.component.html',
})
export class ConfirmRegistrationComponent implements OnInit {
constructor(private route: ActivatedRoute,
private router: Router) { }
ngOnInit() {
this.route.params.switchMap((params: Params) => {
return console.log('token:', params['registrationToken']);
});
}
}
创建我的角CLI项目,负载参数的简单组件读取PARAMS,但我得到的错误:
无法编译。
.../confirm-registration.component.ts (15,33): Argument of type '(params: Params) => void' is not assignable to parameter of type '(value: Params, index: number) => ObservableInput<{}>'. Type 'void' is not assignable to type 'ObservableInput<{}>'.
我在4.0.3版本中使用Angular。我犯了什么错误?
你可以试试这个的console.log(this.route.snapshot.params [“registrationToken”]) –
什么是你的路线,可在req.query –
你正在使用switchMap,它应该返回一个Observable,但你返回调用'console.log'的结果(在这种情况下:void)。请使用'do'操作程序登录到控制台进行调试: – dzejdzej