I recently migrated from ngRoute to ui-router. I have a page that has 2 sections.
Right section displays current item details, Left section shows similar items to current item.
Once user clicks a similar item from left list, right section will reload with clicked item id and left section will stay same.
To keep left section still on user item navigations, i defined left section as an abstract state and right section as it's child state. (you cant view similar items if you arent looking to an item).
Left section (listview) is parent and contains a ui-view in HTML to embed item details.
To load similar items on page open, i need to know which item is being loaded by my child state. But i cant define same url for both abstract state and it's child state. i tried to resolve $stateParams in abstract state with no chance.
my state configuration is below
app.config(['$stateProvider', function ($stateProvider) {
$stateProvider
.state('item', {
//url: '/items/:itemName/:itemID'
url: '/items',
abstract: true,
templateUrl: 'Scripts/app/item/ItemListTemplate.html',
controller: 'ItemListController as itemList'
}).state('item.itemDetails', {
url: '/:itemName/:itemID',
templateUrl: 'Scripts/app/item/ItemDetailTemplate.html',
controller: 'ItemDetailController as itemDetail'
});
how can i access itemID from my abstract state (from ItemListController)?
itemurl to/items/:itemName/:itemIDanditem.detailsto/details. To me - more reasonable.itemsshould be reserved for/itemswhere you display a list and has nothing to do with single view. As abstract state can't be initialised, you won't be able to access/itemsroute directly which kinda kills your flow. To load similar items, wrap them in a directive and access$stateProvider.currentto get params & data to retrieve similar items. Take a look at properties section here -> angular-ui.github.io/ui-router/site/#/api/…