diff options
Diffstat (limited to 'docs/src/templates/docs.js')
| -rw-r--r-- | docs/src/templates/docs.js | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/docs/src/templates/docs.js b/docs/src/templates/docs.js index ab96a699..e244bc7e 100644 --- a/docs/src/templates/docs.js +++ b/docs/src/templates/docs.js @@ -2,26 +2,27 @@ DocsController.$inject = ['$location', '$browser', '$window']; function DocsController($location, $browser, $window) { this.pages = NG_PAGES; window.$root = this.$root; + this.$location = $location; + + this.$watch('$location.hashPath', function(hashPath){ + hashPath = hashPath || '!angular'; + if (hashPath.match(/^!/)) { + this.partialId = hashPath.substring(1); + this.partialTitle = (angular.Array.filter(NG_PAGES, {id:this.partialId})[0]||{}).name; + } + }); this.getUrl = function(page){ return '#!' + page.id; }; this.getCurrentPartial = function(){ - return './' + this.getTitle() + '.html'; - }; - - this.getTitle = function(){ - var hashPath = $location.hashPath || '!angular'; - if (hashPath.match(/^!/)) { - this.partialTitle = hashPath.substring(1); - } - return this.partialTitle; + return './' + this.partialId + '.html'; }; this.getClass = function(page) { var depth = page.depth, - cssClass = 'level-' + depth + (page.name == this.getTitle() ? ' selected' : ''); + cssClass = 'level-' + depth + (page.name == this.partialId ? ' selected' : ''); if (depth == 1 && page.type !== 'overview') cssClass += ' level-angular'; |
