docs(api/cheatsheet): show ng version + lang in page header (#2918)

This commit is contained in:
Patrice Chalin 2016-12-01 11:47:58 -08:00 committed by Filipe Silva
parent c7717b4850
commit 4a0c3d79b7
8 changed files with 22 additions and 19 deletions

View File

@ -13,8 +13,12 @@
if current.path[4] && current.path[3] == 'api' if current.path[4] && current.path[3] == 'api'
- var textFormat = 'is-standard-case' - var textFormat = 'is-standard-case'
if current.path.indexOf('cheatsheet') > 0 || current.path[current.path.length-2] === 'api'
- var base = current.path[4] ? '../guide' : './guide';
- var ngVersion = '(v<ngio-cheatsheet src="' + base + '/cheatsheet.json" version-only>2.X.Y</ngio-cheatsheet>)';
header.hero.background-sky header.hero.background-sky
h1(class="hero-title #{textFormat}") #{headerTitle} h1(class="hero-title #{textFormat}") #{headerTitle} !{ngVersion}
if useBadges if useBadges
if stability if stability

View File

@ -49,9 +49,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"subtitle": "Dart", "subtitle": "Dart",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)",
"reference": false "reference": false
}, },

View File

@ -69,8 +69,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)", "subtitle": "Dart",
"nextable": true, "nextable": true,
"basics": true "basics": true
}, },

View File

@ -41,9 +41,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"subtitle": "JavaScript", "subtitle": "JavaScript",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)",
"reference": false "reference": false
}, },

View File

@ -51,8 +51,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)", "subtitle": "JavaScript",
"nextable": true, "nextable": true,
"basics": true "basics": true
}, },

View File

@ -49,9 +49,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"subtitle": "TypeScript", "subtitle": "TypeScript",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)",
"reference": false "reference": false
}, },

View File

@ -78,8 +78,8 @@
}, },
"cheatsheet": { "cheatsheet": {
"title": "Angular Cheat Sheet", "title": "Cheat Sheet",
"intro": "A quick guide to Angular syntax. (Content is provisional and may change.)", "subtitle": "TypeScript",
"nextable": true, "nextable": true,
"basics": true "basics": true
}, },

View File

@ -1,21 +1,23 @@
angularIO.directive('ngioCheatsheet', function() { angularIO.directive('ngioCheatsheet', function() {
return { return {
restrict: 'E',
scope: {},
controllerAs: '$ctrl', controllerAs: '$ctrl',
controller: function($http, $attrs, $sce) { controller: function($http, $attrs, $sce) {
var $ctrl = this; var $ctrl = this;
$http.get($attrs.src).then(function(response) { $http.get($attrs.src).then(function(response) {
$ctrl.currentEnvironment = response.data.currentEnvironment; if ($attrs.hasOwnProperty('versionOnly')) {
$ctrl.version = response.data.version; $ctrl.version = response.data.version.raw;
$ctrl.sections = response.data.sections; } else {
$ctrl.sections = response.data.sections;
}
}); });
$ctrl.getSafeHtml = function(html) { $ctrl.getSafeHtml = function(html) {
return $sce.trustAsHtml(html); return $sce.trustAsHtml(html);
}; };
}, },
template: template:
'<h2>Angular for {{$ctrl.currentEnvironment}} Cheat Sheet (v{{ $ctrl.version.raw }})</h2>' + '<span ng-if="$ctrl.version">{{$ctrl.version}}</span>' +
'<br>' +
'<div ng-if="!$ctrl.sections">Loading Cheatsheet...</div>\n' +
'<table ng-repeat="section in $ctrl.sections" ng-cloak>\n' + '<table ng-repeat="section in $ctrl.sections" ng-cloak>\n' +
'<tr>\n' + '<tr>\n' +
' <th>{{section.name}}</th>\n' + ' <th>{{section.name}}</th>\n' +