I can’t get the course parameters at angle 5

Asked

Viewed 498 times

1

Every time I try to get the parameters of a route I get an empty object

component:

ngOnInit() {
        this.route.params.subscribe(
            params => {
                this.token = params
                console.log(this.token)
            }
        )
}

routing-module:

const appRoutes: Routes = [
    { 
        path: 'recuperar-senha/:token',
        component: RedefinirSenhaComponent
    }
]

the result of the Component log is always an empty object and my biggest doubt is, this may be being caused by the route authentication?

1 answer

1

Try:

const token = this.activatedRoute.snapshot.params.token;

Don’t forget to put in constructor

private activatedRoute: ActivatedRoute  

Browser other questions tagged

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