forked from angular/angular.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheatsheet.js
30 lines (30 loc) · 1.14 KB
/
cheatsheet.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
angularIO.directive('ngioCheatsheet', function() {
return {
controllerAs: '$ctrl',
controller: function($http, $attrs, $sce) {
var $ctrl = this;
$http.get($attrs.src).then(function(response) {
$ctrl.currentEnvironment = response.data.currentEnvironment;
$ctrl.version = response.data.version;
$ctrl.sections = response.data.sections;
});
$ctrl.getSafeHtml = function(html) {
return $sce.trustAsHtml(html);
};
},
template:
'<h2>Angular for {{$ctrl.currentEnvironment}} Cheat Sheet (v{{ $ctrl.version.raw }})</h2>' +
'<br>' +
'<div ng-if="!$ctrl.sections">Loading Cheatsheet...</div>\n' +
'<table ng-repeat="section in $ctrl.sections" ng-cloak>\n' +
'<tr>\n' +
' <th>{{section.name}}</th>\n' +
' <th ng-bind-html="$ctrl.getSafeHtml(section.description)"></th>\n' +
'</tr>\n' +
'<tr ng-repeat="child in section.items">\n' +
' <td><code bold="child.bold" ng-compile="true">{{child.syntax}}</code></td>\n' +
' <td ng-bind-html="$ctrl.getSafeHtml(child.description)"></td>\n' +
'</tr>\n' +
'</table>'
};
});