My Angular routing configuration using ui-router is quite simple:
$stateProvider
.state("master", {
abstract: true,
url: "/{tenantName}"
})
.state("master.home", {
url: "",
})
.state("master.login", {
url: "/login"
})
I want to ensure that if there is no parameter in the URL, it does not match any state and instead goes to a default state. However, I'm facing two challenges:
The 'master.home' state currently matches the URL with just the domain (e.g.,
domain.com
) when I want the parameter to be mandatory (e.g.,domain.com/hello
). The only solution I've found involves using a non-empty regular expression, but I'm hoping for a better approach.I'm unsure how to define a proper default state. It appears that the only option is to create a state with a "" URL (once issue 1 is resolved) and then use the .otherwise method to redirect to that state's URL.