R
R
Roman Khegay2020-06-19 12:39:12
Angular
Roman Khegay, 2020-06-19 12:39:12

ActivatedRoute data.path returns undefined, in case of access to a non-existent route?

There is such an idea | GitHub repository

The essence of the idea: when accessing a non-existent route, offer a link that matches the name.

Route for 404:

{ path: '**', resolve: { path: PathResolveService }, component: NotFoundComponent }


NotFoundComponent method during NgOnInit, route: ActivatedRoute:
this.route.data.pipe(take(1))
    .subscribe((data: { path: string }) => {
         this.path = data.path;
    })


The problem occurs when accessing ActivatedRoute .data.path: in all cases, undefined is returned.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question