In my application I've got an overview of different franchise locations which are coming from an online service. Every location has a link which should normally go to a new nested state. My state looks like this, I'm also using resolve so that I can search for the location by id.
.state('locations', {
url: "/locations",
controller: "FranchiseCtrl",
templateUrl: "partials/locations.html"
})
.state('locations.location', {
params: {
locationId : "defaultID",
locationName: "defaultName"
},
url: "/:locationName",
controller: "LocationCtrl",
templateUrl: "partials/location.html",
resolve: {
loc: function($http, $stateParams) {
var url = "url/to/service/" + $stateParams.locationId + "/en";
return $http.get(url)
.then(function(res){ return res.data; });
}
}
})
This is the link in the locations.html
<a ui-sref="locations.location({ locationId: location.id, locationName: location.name })">Go to location</a>
When I click on the link my url changes to the correct location but i'm not going to the templateUrl for the state.