UNPKG

suh-dgeni-ngdocs

Version:

A package to generate ng-docs similar to what is used on AngularJS website.

34 lines (28 loc) 915 B
"use strict"; angular.module('versions', []) .controller('DocsVersionsCtrl', ['$scope', '$location', '$window', 'NG_VERSIONS', function($scope, $location, $window, NG_VERSIONS) { $scope.docs_version = NG_VERSIONS[0]; $scope.docs_versions = NG_VERSIONS; for(var i=0, minor = NaN; i < NG_VERSIONS.length; i++) { var version = NG_VERSIONS[i]; // NaN will give false here if (minor <= version.minor) { continue; } version.isLatest = true; minor = version.minor; } $scope.getGroupName = function(v) { return v.isLatest ? 'Latest' : ('v' + v.major + '.' + v.minor + '.x'); }; $scope.jumpToDocsVersion = function(version) { var currentPagePath = $location.path().replace(/\/$/, ''), url = ''; if (version.isOldDocsUrl) { url = version.docsUrl; }else{ url = version.docsUrl + currentPagePath; } $window.location = url; }; }]);