This is my code:
ngOnInit() {
this.route.paramMap.subscribe(params => {
console.log(params.get('id')); // THIS IS WORKS
this.currentOrganization = this.getOrganizationId(params.get('id'));
console.log(this.currentOrganization); // THIS IS UNDEFINED
} );
}
getOrganizationId(id: string) {
let organizations = this.orgService.getOrganizations(); // THIS IS WORKS
return organizations.find(p => p.id == id);
}
Why undefined this.currentOrganization? How do I get the organization's information for params.get('id')?