Durandal and MVC4 Areas for multiple SPAs

百般思念 提交于 2019-12-03 03:35:01

You might want to consider your deployment strategy. For example, if you need to optimize this app, both SPAs will end up in the same file. However, instead of having them both under the app folder, you can make separate folders, and give each SPA it's own main.js file.

In more advanced scenarios, you may create a "bootstrapper" app that loads one or another of the SPAs. The bootstrapper would contain code that is common to both SPAs. But each SPA (and the bootstrapper) can be optimized independently.

There are many options. Mainly, consider your final deployment strategy and that will help guide you here.

Also, the issue you have above is probably related to the fact that the standard conventions may not work in your setup, and you would need to override some functions with your own mapping.

I ran into the exact same problem this morning. I originally formatted the project to be:

  • app/spa1/viewmodels
  • app/spa1/views
  • app/spa2/viewmodels
  • app/spa2/views

Using this structure I hit the exact same wall you did. After reading your post, I restructured the project to be:

  • app/viewmodels/spa1
  • app/viewmodels/spa2
  • app/views/spa1
  • app/views/spa2

Using this structure, navigation works fine. I set up three SPAS and was able to navigate all three. The other benefit of this structure is that you are now following the standard convention so you don't have to configure the view locator. Just make sure the main.js file for each spa uses:

  • app.setRoot('view models/spa1/shell), app.setRoot('view models/spa2/shell), etc.

Finally, by structuring this way, you move the main.js files up the structure which eliminates the ../../../ in all your defines.

I hope this helps.

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