I'm new to durandal. I just wondered if there was a way to pass in variables to the root view model aka the shell, either via querystring or any other way?
so main.js looks something like the below
define(['durandal/app'], function (app) {
app.configurePlugins({
router: true
});
app.start().then(function () {
app.setRoot('shell');
});
});
Can you do something similar to what's written below in the shell.js file. I tried it but it doesn't work
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);
}
I can't make a call to a service to get the data in the shell as the information/variable I want is passed into the page that leads to the spa as a querystring parameter.
So, is it possible to pass something into the shell, or is there any other alternative to achieve what I want. Like creating a cookie to store this variable and reading it via javascript in shell.js?