Frédéric Vachon e0f1606a5a Drupal detailed view
Change-Id: I5a5d93247dc5b9210f4ca7e4eafeb41f1239fac2
2015-06-05 17:06:48 -04:00

36 lines
1.3 KiB
JavaScript
Raw Permalink 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('bansho.drupal', ['bansho.surveil'])
.value('drupalConfig', {})
.controller('DrupalCtrl', ['$scope', 'drupalConfig', 'surveilStatus',
function ($scope, drupalConfig, surveilStatus) {
$scope.hostName = drupalConfig.hostName;
}])
.directive('banshoDrupal', ['$http', '$compile', 'surveilStatus', 'drupalConfig',
function ($http, $compile, surveilStatus, drupalConfig) {
return {
restrict: 'E',
compile: function () {
return function (scope, element, attrs) {
var template = 'components/drupal/drupal.html';
if (!attrs.hostName) {
throw new Error('<bansho-drupal> "host-name" attribute must be defined');
}
drupalConfig.hostName = {};
drupalConfig.hostName = attrs.hostName;
$http.get(template, { cache: true })
.success(function (data) {
var elem = $compile(data)(scope);
element.append(elem);
});
};
}
};
}]);