Durandal 사이트로 돌아 가면 HTML samples.zip 파일을 다운로드하십시오. 그 나쁜 소년을 불 태워라. 그러면 코 샘플이 당신이 찾고있는 것을 정확하게하고있는 것을 볼 것이다.
(KO로 샘플 폴더에서하는 index.js 파일의 복사)
define(['plugins/router', 'knockout'], function(router, ko) {
var childRouter = router.createChildRouter()
.makeRelative({
moduleId:'ko',
fromParent:true
}).map([
{ route: '', moduleId: 'helloWorld/index', title: 'Hello World', type: 'intro' },
{ route: 'helloWorld', moduleId: 'helloWorld/index', title: 'Hello World', type: 'intro', nav: true},
{ route: 'clickCounter', moduleId: 'clickCounter/index', title: 'Click Counter', type: 'intro', nav: true},
{ route: 'simpleList', moduleId: 'simpleList/index', title: 'Simple List', type: 'intro', nav: true },
{ route: 'betterList', moduleId: 'betterList/index', title: 'Better List', type: 'intro', nav: true},
{ route: 'controlTypes', moduleId: 'controlTypes/index', title: 'Control Types', type: 'intro', nav: true },
{ route: 'collections', moduleId: 'collections/index', title: 'Collection', type: 'intro' , nav: true },
{ route: 'pagedGrid', moduleId: 'pagedGrid/index', title: 'Paged Grid', type: 'intro', nav: true },
{ route: 'animatedTrans', moduleId: 'animatedTrans/index', title: 'Animated Transition', type: 'intro', nav: true },
{ route: 'contactsEditor', moduleId: 'contactsEditor/index', title: 'Contacts Editor', type: 'detailed', nav: true },
{ route: 'gridEditor', moduleId: 'gridEditor/index', title: 'Grid Editor', type: 'detailed', nav: true },
{ route: 'shoppingCart', moduleId: 'shoppingCart/index', title: 'Shopping Cart', type: 'detailed', nav: true },
{ route: 'twitterClient', moduleId: 'twitterClient/index', title: 'Twitter Client', type: 'detailed', nav: true}
]).buildNavigationModel();
return {
router: childRouter,
introSamples: ko.computed(function() {
return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {
return route.type == 'intro';
});
}),
detailedSamples: ko.computed(function() {
return ko.utils.arrayFilter(childRouter.navigationModel(), function(route) {
return route.type == 'detailed';
});
})
};
});
당신은 당신이 시도 어떤 코드를 포함해야합니다. 당신이 설명하는 것은 상당히 간단합니다. –
프로젝트의 JS 부분 또는 HTML 부분을 의미합니까? 프로젝트 코드를 직접 복사/붙여 넣기 할 수 없으므로 샘플을 준비해 둡니다. 처음에는 ko.observable ActiveView를 사용하여 modulID를 해당 속성으로 정의한 다음 해당 속성을 자식 뷰 외부에 바인딩하는 것이 었습니다. 이게 좋은 생각이라고 생각하니? –
샘플은 좋은 생각입니다. 나는 종종 문제가 무엇인지 고민하고있을 때, 고립 된 예에서 문제를 재현 해 내면 문제를 명확하게 파악하기가 쉽다는 것을 알게되었습니다. –