Javascript DurandalJS:activate()回调在路由参数更改后未在合成中运行
以下是我的设置:Javascript DurandalJS:activate()回调在路由参数更改后未在合成中运行,javascript,durandal,Javascript,Durandal,以下是我的设置: shell.js(包括主路由器) shell.html 办公室 shell.js(包括子路由器) shell.html sidebar.js sidebar.html 员工 index.html index.js 主shell包括一个指向office页面的路由,该页面包含属于该办公室的员工列表: { route: 'offices/:id', moduleId: 'offices/shell' } 子shell包括一个指向office页面侧栏的组合 <asi
- shell.js(包括主路由器)
- shell.html
- 办公室
- shell.js(包括子路由器)
- shell.html
- sidebar.js
- sidebar.html
- 员工
- index.html
- index.js
{ route: 'offices/:id', moduleId: 'offices/shell' }
子shell包括一个指向office页面侧栏的组合
<aside data-bind="compose: { model:'offices/sidebar', view:'offices/sidebar' }"></aside>
问题是sidebar.js中的activate回调仅在我第一次加载页面时运行,而不是在路由的id参数更改时运行
因此,当我从offices/12
更改为offices/15
时,唯一运行的是offices/shell.js内部的激活回调和employees/index.js内部的激活回调
有没有办法重新激活这篇作文
谢谢 如果侧边栏是单例的,那么它当然不会在路由更改时重新激活。考虑在激活新路径或任何东西时将一些对象传递到侧栏。不,我将侧边栏作为函数返回。我该怎么做?