I am using durandal version 1.1. From compose binding I am passing some extra parameters through activationData. But the child viewmodel does not get the value. It is always received as undefined in the activate method.
<div data-bind="compose: {
model: 'testmodel',
activationData: {data : 10},
activate: true
}">
</div>
The activate method looks like:
define(['durandal/app', 'durandal/system', 'durandal/plugins/router', 'services/logger', 'services/datacontext', 'config'], function (app, system, router, logger, Datacontext, config) {
var testmodel= function () {
var vm = this;
vm.activate = function (activationData) {
alert(activationData);
logger.log('View Activated',
null, 'test', true);
};
};
return testmodel;
});
Also added activate to prototype but that does not work as well:
define(['durandal/app', 'durandal/system', 'durandal/plugins/router', 'services/logger', 'services/datacontext', 'config'], function (app, system, router, logger, Datacontext, config) {
var testmodel= function () {
var vm = this;
};
testmodel.prototype.activate = function (activationData) {
alert(activationData);
logger.log('View Activated',
null, 'test', true);
};
return testmodel;
});
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…