我正在尝试提取数组的元素,但似乎未定义。
ngOnInit() {
this.route.params.subscribe(
(params : Params) =>{
this.id = params.id;
});
this.store.select('users').subscribe( data => {
this.users = data.users;
});
this.userService.getUserDetails(this.users[this.id].userId).subscribe(
user => {
this.userToEdit = user.Data;
console.log(this.userToEdit); <- this is showing the object
})
console.log(this.userToEdit); <- undefined
this.initForm();
}
我应该如何在那个时候同时在订阅功能之外设置值。