Created
September 5, 2012 21:11
-
-
Save sshirokov/3644829 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| angular.module('gitstats').controller "NavCtrl", ['$scope', '$route', | |
| class NavCtrl | |
| constructor: (@scope, @route) -> | |
| route_to_nav = (path, route) => | |
| return if route.redirectTo? | |
| return unless route.name? | |
| current_route_name = () => @route.current?.$route?.name | |
| path: path | |
| name: route.name | |
| classes: -> | |
| "active" if @name == current_route_name() | |
| # The navs are built out of the routing table | |
| # with any redirecting routes or routes without | |
| # names omitted. | |
| @scope.navs = (route_to_nav(path, route) for own path, route of @route.routes).filter (r) => r | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <ul class="nav" ng-controller="NavCtrl"> | |
| <li ng-repeat="nav in navs" ng-class="nav.classes()"> | |
| <a ng-href="#{{ nav.path }}" >{{ nav.name }}</a> | |
| </li> | |
| </ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment