mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-04-21 10:05:34 +08:00
Because `https://docs.angularjs.org/api/` can handler the trailing slash, but `https://code.angularjs.org/1.2.24/docs/api` can not. Fix #9043 Closes #9045
30 lines
877 B
JavaScript
30 lines
877 B
JavaScript
angular.module('versions', [])
|
|
|
|
.controller('DocsVersionsCtrl', ['$scope', '$location', '$window', 'NG_VERSIONS', function($scope, $location, $window, NG_VERSIONS) {
|
|
$scope.docs_version = NG_VERSIONS[0];
|
|
|
|
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.docs_versions = NG_VERSIONS;
|
|
$scope.getGroupName = function(v) {
|
|
return v.isLatest ? 'Latest' : (v.isStable ? 'Stable' : 'Unstable');
|
|
};
|
|
|
|
$scope.jumpToDocsVersion = function(version) {
|
|
var currentPagePath = $location.path().replace(/\/$/, '');
|
|
|
|
// TODO: We need to do some munging of the path for different versions of the API...
|
|
|
|
|
|
$window.location = version.docsUrl + currentPagePath;
|
|
};
|
|
}]);
|