2015-03-26 16:17:08 -04:00

42 lines
1.4 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.host', ['adagios.live'])
.value('hostConfig', {})
.controller('HostCtrl', ['$scope', 'hostConfig', 'addObjectToScope', function ($scope, hostConfig, addObjectToScope) {
var objectType = 'host',
objectIdentifier = {};
objectIdentifier.host_name = hostConfig.hostName;
$scope.data = {};
addObjectToScope(objectType, objectIdentifier, $scope);
}])
.directive('adgHost', ['$http', '$compile', 'hostConfig',
function ($http, $compile, hostConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/host/host.html';
if (!attrs.hostName) {
throw new Error('<adg-host> "host-name" attribute must be defined');
}
hostConfig.hostName = {};
hostConfig.hostName = attrs.hostName;
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}]);