bansho/app/components/service/service.js

47 lines
1.7 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
angular.module('adagios.service', ['adagios.live'])
.value('serviceConfig', {})
.controller('ServiceCtrl', ['$scope', 'serviceConfig', 'getService',
function ($scope, serviceConfig, getService) {
var objectType = 'service',
hostName = serviceConfig.hostName,
description = serviceConfig.description;
getService(hostName, description).success(function (data) {
$scope.data = data;
console.log($scope.data);
});
}])
.directive('adgService', ['$http', '$compile', 'serviceConfig',
function ($http, $compile, serviceConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/service/service.html';
if (!attrs.hostName && !!attrs.description) {
throw new Error('<adg-service> "host-name" and "description" attributes must be defined');
}
serviceConfig.hostName = '';
serviceConfig.hostName = attrs.hostName;
serviceConfig.description = '';
serviceConfig.description = attrs.description;
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}]);