Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 1 | import './nav.scss'; |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 2 | import {IXosNavigationService, IXosNavigationRoute} from '../services/navigation'; |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 3 | |
| 4 | class NavCtrl { |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 5 | static $inject = ['$state', 'NavigationService']; |
| 6 | public routes: IXosNavigationRoute[]; |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 7 | |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 8 | constructor( |
| 9 | private $state: angular.ui.IStateService, |
| 10 | private navigationService: IXosNavigationService |
| 11 | ) { |
Matteo Scandolo | 3b3b3b4 | 2016-12-15 17:31:53 -0800 | [diff] [blame] | 12 | // NOTE we'll need to have: |
| 13 | // - Base routes (defined from configuration based on BRAND) |
| 14 | // - Autogenerated routes (nested somewhere) |
| 15 | // - Service Routes (dynamically added) |
Matteo Scandolo | f2c3ed6 | 2016-12-15 14:32:50 -0800 | [diff] [blame] | 16 | this.routes = this.navigationService.query(); |
| 17 | } |
| 18 | |
| 19 | isRouteActive(route: IXosNavigationRoute) { |
| 20 | return this.$state.current.url === route.url ? 'active' : ''; |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 21 | } |
| 22 | } |
| 23 | |
| 24 | export const xosNav: angular.IComponentOptions = { |
| 25 | template: require('./nav.html'), |
| 26 | controllerAs: 'vm', |
| 27 | controller: NavCtrl |
| 28 | }; |