mirror of
https://github.com/nasa/openmct.git
synced 2025-01-27 22:59:37 +00:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
/*global define,Promise*/
|
||
|
|
||
|
/**
|
||
|
* Module defining MCTInclude. Created by vwoeltje on 11/7/14.
|
||
|
*/
|
||
|
define(
|
||
|
[],
|
||
|
function () {
|
||
|
"use strict";
|
||
|
|
||
|
/**
|
||
|
* Defines the mct-include directive. This acts like the
|
||
|
* ng-include directive, except it accepts a symbolic
|
||
|
* key which can be exposed by bundles.
|
||
|
* @constructor
|
||
|
*/
|
||
|
function MCTInclude(templates) {
|
||
|
var templateMap = {};
|
||
|
|
||
|
templates.forEach(function (template) {
|
||
|
var path = [
|
||
|
template.bundle.path,
|
||
|
template.bundle.resources,
|
||
|
template.templateUrl
|
||
|
].join("/");
|
||
|
templateMap[template.key] = path;
|
||
|
});
|
||
|
|
||
|
function controller($scope) {
|
||
|
$scope.inclusion = templateMap[$scope.key];
|
||
|
}
|
||
|
|
||
|
return {
|
||
|
restrict: "E",
|
||
|
controller: controller,
|
||
|
template: '<ng-include src="inclusion"></ng-include>',
|
||
|
scope: { key: "=", ngModel: "=", parameters: "=" }
|
||
|
};
|
||
|
}
|
||
|
|
||
|
return MCTInclude;
|
||
|
}
|
||
|
);
|