I want to make tabs with tab-content. tab-content has it's own view. Here is code sample
(function () {
angular
.module('infirma.konfiguracja', ['ui.router'])
.config(routeConfig)
;
routeConfig.$inject = ['$stateProvider'];
function routeConfig($stateProvider) {
$stateProvider
.state('app.konfiguracja', {
url: 'konfiguracja/',
views: {
'page@app': {
templateUrl: 'app/konfiguracja/lista.html',
controller: 'konfiguracjaListaCtrl',
controllerAs: 'vm'
}
},
ncyBreadcrumb: {label: "Ustawienia systemu"}
})
.state('app.konfiguracja.dzial', {
url: '{dzial:.*}/',
views: {
'dzial@app.konfiguracja': {
templateUrl: 'app/konfiguracja/dzial.html',
controller: 'konfiguracjaDzialCtrl',
controllerAs: 'vm'
}
},
ncyBreadcrumb: {label: "{{vm.nazwaDzialu}}"}
})
;
}
})();
I want to mark selected tab which is in parent state (app.konfiguracja
).
Problem is that when entering url like /konfiguracja/firmy/
there is no $stateParams.dzial
in app.konfiguracja
controller
How to fix it?
I created working example for your scenario here. I would say, that there at least two ways.
The first, general way, how we should use the
UI-Router
and its selected params in parent views (to mark selected tab/link), should be with a directive**ui-sref-active**
:So this could be the usage:
The second approach (my preferred) would be to use a reference
Model
, created in parent$scope
, and filled in a child:usage could be then like this
How is the second approach working? check the DOC:
Scope Inheritance by View Hierarchy Only
Check that all in action here