mirror of
https://github.com/nasa/openmct.git
synced 2025-06-12 20:28:14 +00:00
[Representation] Initial representation bundle
Initial transition of bundle platform/representation from sandbox branch. WTD-521.
This commit is contained in:
43
platform/representation/src/MCTInclude.js
Normal file
43
platform/representation/src/MCTInclude.js
Normal file
@ -0,0 +1,43 @@
|
||||
/*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;
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user