Can Durandaljs do Areas

痞子三分冷 提交于 2019-12-04 14:07:06

问题


I'm trying to see if there is a way to do areas in Durandaljs

Something along the lines of

/App/areas/home
                /views
                /viewmodels
          /other
                /views
                /viewmodels

I see the viewLocator allowing this convention:

 viewLocator.useConvention('viewmodels', 'views', 'areas');

but the router.useConvention() seems to default to same path.

Is there a proper way to account for this, the documentation is light in this regard.


回答1:


yes you can do this.

Since you are using Durandal.router you can use a convention of where to find your ViewModels by overriding the routers autoConvertRouteToModuleId like so:

router.autoConvertRouteToModuleId = function(url, params) {
    return url + '/' + 'params[0]';
};

As for finding the view that binds to your viewmodel then you can like you have above.. change the viewlocator convention.



来源:https://stackoverflow.com/questions/15416494/can-durandaljs-do-areas

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!