The ‘Add’ button on a page usually routes to the page with an id URL parameter, so there’s a new instance of the Bus Obj being produced.
But you want to recognize whether the page is being called as an add (new), an edit (existing) or a create (new version).
So how can this be recognized?
To comment on add (new) vs create (new version), I would need more understanding of your data model and how you are handling versions.
I can think of two patterns for determining if it is a new or existing case. The first is by looking at the data. An example may be that the status is “draft” (or maybe even has no value) on a new item. The destination page could then apply logic accordingly.
Another approach would be to have the add button “added” event trigger a method in the page where the add button lives. That trigger method could add a query parameter to the call to this.router.navigate:
this.router.navigate(['/your-route'], {
queryParams: {
isNew: true
}
});
Then in the destination page, you could look for the query parameter to determine which case it is:
this.subscription = this.route.queryParams.subscribe((params) => {
this.isNew = params.isNeq;
});