I have a component that handles both creating new items and updating existing ones. I have set up a Resolver for the 'edit/:id' route, but have not used one for the 'new' route.
ngOnInit() {
if (!(this.route.snapshot.url[0].path === '/new')) {
this.route.data
.subscribe((data: { project: Project}) => {
this.project= data.project;
});
}
}
I have been able to retrieve two different URLs, one showing the full path and the other only displaying the last part of the path.
this.route.snapshot.url[0].path
// Result: 'new'
this.router.url
// Result: '/admin/projects/new'
I am exploring better ways to determine when to load resolver data and when not to. Is using the URL a good approach? If so, which URL variable would you recommend?