How to recover data from Angular Route component?

Asked

Viewed 205 times

1

I saw in the documentation Angular that it is possible to recover data stored in the property date (receiving an object) from a route. I have, in this case an application with the following routes:

const routes: Routes = [
  {
    path: '',
    component: UserComponent,
    data: {
      title: 'Home'
    }
  },
  {
    path: 'bank-accounts',
    component: BankAccountsComponent,
    data: {
      title: 'Contas correntes'
    }
  },
];

How can I recover this data (the title in case) in a route?

1 answer

4


  • then I take the property sub and do this.sub.title to recover the data, this?

  • 1

    To recover the Voce data you must store the variable v in an internal variable. I edited the response to give an alert showing the recovered value.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.