I'm using UI-Router and I need to hook up tabs where the url changes as well. So for example, I have a page with 3 sublinks:
- Customer Overview (templates/customer.overview.html): example.com/customer/:id/overview
- Customer Settings (templates/customer.settings.html): example.com/customer/:id/settings
- Customer Contact Info (templates/customer.contact.html): example.com/customer/:id/contact
All three of these pages should be injected into one main customers.main.html
page that includes the links.
My states are defined as follows:
$stateProvider
.state('customer', {
abstract: true,
url: '/customer',
templateProvider: function($templateCache) {
return $templateCache.get('templates/customer.overview.html');
}
})
.state('customer.overview', {
url:'/:id/overview',
controller: ''
templateProvider: function($templateCache) {
return $templateCache.get('templates/customer.settings.html');
}
})
.state('customer.contact', {
url:'/:id/contact',
controller: ''
templateProvider: function($templateCache) {
return $templateCache.get('templates/customer.contact.html');
}
});
And I have a customers.main.html
page:
<div class="tabs" ng-controller="TabsCtrl as tabs">
<a ng-repeat="tab in tabs" ui-sref='{{tab.route}}' ng-bind="tab.label">
</div>
TabsCtrl
angular.module('customers')
.controller('TabsCtrl', [
function() {
var self = this;
self.tabs = [
{
label: 'Overview',
route: 'customer.overview',
active: false
},
{
label: 'Settings',
route: 'customer.settings',
active: false
},
{
label: 'Contact',
route: 'customer.contact',
active: false
}
];
self.selectedTab = self.tabs[0];
}
]);
However, this doesn't seem to be working correctly. The ui-sref
directive when I click always resolves to something like: /customers//settings
. It's not picking up the :id
.
Any help?