I encountered what I thought would be a common issue, but my search turned up empty. I have two states - one accessed at /route
and the other at /route/{name}
. Everything functions properly when I navigate to the second route using ui-sref
, however, if I refresh the page or visit the URL directly, it redirects me back to the /route
page even though the URL in the browser remains unchanged. How can this be resolved?
function Routes($stateProvider) {
$stateProvider.state("route1", {
url: "/route",
templateUrl: "js/route/route1.html",
controller: "Route1Controller",
controllerAs: "vm",
resolve: {
...
}
})
.state("route2", {
url: "/route/{name}",
templateUrl: "js/route/route2.html",
controller: "Route2Controller",
controllerAs: "vm",
resolve: {
...
}
});
}
Edit: To clarify, I want route2
to behave like any other state with a completely distinct URL. If the URLs were "/route1" and "/route2", nested views wouldn't even be suggested. If fixing this isn't feasible, I may have to consider employing a nested view within the route1
template.
Edit2: The issue did not lie in the provided code. An additional route "/route/:id" was causing the conflict due to an undefined type. This resulted in both routes being the same. Upon defining the types ("/route/{id:int}"), the problem was resolved.