[API] Get View to render

This commit is contained in:
Victor Woeltjen 2016-05-27 16:36:55 -07:00
parent 7205faa6bb
commit 03cb0ccb57
6 changed files with 26 additions and 10 deletions

View File

@ -64,6 +64,8 @@ define([
'legacyRegistry',
'./src/MCT',
'./src/adapter/bundle',
'./platform/framework/bundle',
'./platform/core/bundle',
'./platform/representation/bundle',

View File

@ -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[]"]
}
]
}

View File

@ -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: "=",

View File

@ -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);
}

View File

@ -1,9 +1,12 @@
define([
'./Type'
'./Type',
'./View'
], function (
Type
Type,
View
) {
return {
Type: Type
Type: Type,
View: View
};
});

View File

@ -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'),