angular.module('docapp', ['ngSanitize']) .controller('docController', function($scope, $http) { $scope.user = 'Ricardo'; // initialization $http.get('/etbmanager/resources/api/pub/apidoc/groups') .success(function (data) { $scope.doc = data; }); $scope.groupClick = function (grp) { $http.get('/etbmanager/resources/api/pub/apidoc/routes?grp=' + grp.name) .success(function(data) { $scope.loadingRoutes = false; $scope.group = data; var routes = $scope.group.routes; if (routes) { routes.forEach(function(route) { $scope.updateRouteInfo(route); }); } }); $scope.loadingRoutes = true; $scope.group = grp; } $scope.updateRouteInfo = function(route) { if (route.inputObject) { route.inputObjectHTML = genSchemaExample(route.inputObject); } if (route.returnObject) { route.returnObjectHTML = genSchemaExample(route.returnObject); } } $scope.showInputObj = function(it) { it.inputmd = false; } $scope.showInputmd = function(it) { it.inputmd = true; } $scope.showRetObj = function(it) { it.retmd = false; } $scope.showRetmd = function(it) { it.retmd = true; } $scope.toggleDetail = function(it) { it.showDetail = !it.showDetail; } }); function genSchemaExample(schema) { var s = '