Durandal and ASP.NET MVC conventions

前端 未结 2 1673
傲寒
傲寒 2021-02-07 10:45

I\'m currently evaluating Durandal for use in an enterprise ASP.NET MVC application.

However the default conventions used by Durandal

2条回答
  •  北恋
    北恋 (楼主)
    2021-02-07 11:15

    What we do (this is what I have seen Rob doing too:) is that to create folders inside the /App folder depending on the functional areas of the app. Then just create view and view model file inside these folders.

    Trick is to have a "viewUrl" property in each view model to tell durandal which view to use. This way of structuring the application is useful for large projects where there are many views/view models ; avoids confusion when your project grows.

    define(['durandal/app', 'durandal/system', 'plugins/router'],
        function (app, system, router) {
            var vm = {
                viewUrl: 'myfolder/myview.html',
            };
            return vm;
        }
    );
    

    You can still use viewLocator.useConvention(); when you bootstrap your application; durandal will still find the view as long as you have viewUrl property.

提交回复
热议问题