0
我是杜兰达尔的新手。我只是想知道是否有一种方法可以通过查询字符串或任何其他方式将变量传递给根视图模型(也称为shell)?如何将变量传递到壳体或根视图模型中
所以main.js看起来像你可以做类似什么的下面写在shell.js文件的东西下面
define(['durandal/app'], function (app) {
app.configurePlugins({
router: true
});
app.start().then(function() {
app.setRoot('shell');
});
});
。 我尝试过,但它不工作
function activate(variableIwantToPass) {
doSomething(variableIwantToPass);
configureRoutes(variableIwantToPass);
return router.activate();
}
function configureRoutes(variableIwantToPass) {
var specialRoute = 'bar';
if(variableIwantToPass == 'foo') {
specialRoute = foo;
}
var routes = [
{
route: '',
moduleId: 'home'
},
{
route: 'doThings/:specialRoute/',
moduleId: 'orchestrator'
}
];
router.makeRelative({ moduleId: 'viewModels'}).map(routes);
}
我无法拨打电话的服务来获得在shell作为信息/可变我要传递到通向该页面的数据spa作为查询字符串参数。
那么,是否有可能将某些东西传递到shell中,或者是否有其他替代方法来实现我想要的。就像创建一个cookie来存储这个变量并通过shell.js中的javascript读取它?
“你能像shell.js文件中的下面这样东西吗”对我来说没有任何意义,你可能可以重述一下吗? – Shelvacu