0

hi I am trying to display details of a particular id. the details are present in the global variable called 'list' of a service. the id I am getting through route parameters. the details I need to store in a variable named 'editexpense'.

here is my component :

ngOnInit(): void {
  this.a_route.params.subscribe((params)=>this.expense_id=params.Expense_id);
  this.editexpense = this.expense_ser.list
    .find(expense => expense.Expense_id === this.expense_id)
}
Emilien
  • 2,701
  • 4
  • 15
  • 25
Sulo
  • 13
  • 2
  • Duplicate of [How to return value inside subscribe Angular 4](https://stackoverflow.com/questions/49605090/how-to-return-value-inside-subscribe-angular-4) – Guy Incognito Dec 01 '20 at 12:54
  • A subscription is an asynchronous operations.When you do the find this.expense_id is unset. You can put your code in the subscribe function. – Nico Dec 01 '20 at 15:55

0 Answers0