blob: cd249b9eb0194eaf98514a172067c6d5f85df038 [file] [log] [blame]
import './nav.scss';
import {IXosNavigationService, IXosNavigationRoute} from '../services/navigation';
class NavCtrl {
static $inject = ['$scope', '$state', 'NavigationService'];
public routes: IXosNavigationRoute[];
constructor(
private $scope: ng.IScope,
private $state: angular.ui.IStateService,
private navigationService: IXosNavigationService
) {
// NOTE we'll need to have:
// - Base routes (defined from configuration based on BRAND)
// - Autogenerated routes (nested somewhere)
// - Service Routes (dynamically added)
this.$scope.$watch(() => this.navigationService.query(), (routes) => {
this.routes = routes;
});
}
isRouteActive(route: IXosNavigationRoute) {
return this.$state.current.url === route.url ? 'active' : '';
}
activateRoute(route: IXosNavigationRoute) {
route.opened = !route.opened;
}
}
export const xosNav: angular.IComponentOptions = {
template: require('./nav.html'),
controllerAs: 'vm',
controller: NavCtrl
};