简体   繁体   中英

Can Durandaljs do Areas

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM