mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 21:27:52 +00:00
[API] Get View to render
This commit is contained in:
parent
7205faa6bb
commit
03cb0ccb57
2
main.js
2
main.js
@ -64,6 +64,8 @@ define([
|
||||
'legacyRegistry',
|
||||
'./src/MCT',
|
||||
|
||||
'./src/adapter/bundle',
|
||||
|
||||
'./platform/framework/bundle',
|
||||
'./platform/core/bundle',
|
||||
'./platform/representation/bundle',
|
||||
|
@ -2,13 +2,13 @@ define([
|
||||
'legacyRegistry',
|
||||
'./directives/MCTView'
|
||||
], function (legacyRegistry, MCTView) {
|
||||
legacyRegistry.register('adapter', {
|
||||
legacyRegistry.register('src/adapter', {
|
||||
"extensions": {
|
||||
"directives": [
|
||||
{
|
||||
key: "mctView",
|
||||
implementation: MCTView,
|
||||
depends: "newViews[]"
|
||||
depends: ["newViews[]"]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
define(function () {
|
||||
define(['angular'], function (angular) {
|
||||
function MCTView(newViews) {
|
||||
var factories = {};
|
||||
|
||||
@ -7,7 +7,7 @@ define(function () {
|
||||
});
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
restrict: 'E',
|
||||
link: function (scope, element, attrs) {
|
||||
var key = undefined;
|
||||
var mctObject = undefined;
|
||||
@ -21,13 +21,24 @@ define(function () {
|
||||
}
|
||||
|
||||
var view = factories[key](mctObject);
|
||||
var elements = view.elements;
|
||||
var elements = view.elements();
|
||||
element.empty();
|
||||
element.append(elements);
|
||||
}
|
||||
|
||||
function setKey(k) {
|
||||
key = k;
|
||||
maybeShow();
|
||||
}
|
||||
|
||||
function setObject(obj) {
|
||||
mctObject = obj;
|
||||
maybeShow();
|
||||
}
|
||||
|
||||
scope.$watch('key', setKey);
|
||||
scope.$watch('mctObject', setObject);
|
||||
|
||||
},
|
||||
scope: {
|
||||
key: "=",
|
||||
|
@ -16,7 +16,7 @@ define(['EventEmitter'], function (EventEmitter) {
|
||||
this.elements(definition.elements());
|
||||
}
|
||||
if (definition.initialize) {
|
||||
definition.initialize(this.elements(), render);
|
||||
definition.initialize(this.elements(), state, render);
|
||||
}
|
||||
this.on('model', render);
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
define([
|
||||
'./Type'
|
||||
'./Type',
|
||||
'./View'
|
||||
], function (
|
||||
Type
|
||||
Type,
|
||||
View
|
||||
) {
|
||||
return {
|
||||
Type: Type
|
||||
Type: Type,
|
||||
View: View
|
||||
};
|
||||
});
|
||||
|
@ -27,7 +27,7 @@ define([
|
||||
};
|
||||
},
|
||||
elements: $.bind(null, todoTemplate),
|
||||
initialize: function (elements, render) {
|
||||
initialize: function (elements, state, render) {
|
||||
var $els = $(elements);
|
||||
var $buttons = {
|
||||
all: $els.find('.example-todo-button-all'),
|
||||
|
Loading…
Reference in New Issue
Block a user