Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I don't recommend that you use .cshtml files as views directly. You're better off placing the .cshtml files behind a controller.</p> <p>For example, take the HotTowel sample, edit /App/main.js, and replace the function definition with the following:</p> <pre><code>define(['durandal/app', 'durandal/viewLocator', 'durandal/system', 'durandal/plugins/router', 'durandal/viewEngine', 'services/logger'], function (app, viewLocator, system, router, viewEngine, logger) { </code></pre> <p>Note that we added a reference to the Durandal viewEngine. Then we need to replace</p> <pre><code>viewLocator.useConvention(); </code></pre> <p>with</p> <pre><code>viewLocator.useConvention('viewmodels', '../../dynamic'); viewEngine.viewExtension = '/'; </code></pre> <p>The first argument to viewLocation.useConvention sets the /Apps/viewmodels/ directory as the location for the view models js files, but for the view location, uses the URL <a href="http://example.com/dynamic/" rel="noreferrer">http://example.com/dynamic/</a>, with an extension of '/'. So that if Durandal is looking for the view named 'shell', it will reference <a href="http://example.com/dynamic/shell/" rel="noreferrer">http://example.com/dynamic/shell/</a> (this is because the view directory is mapped relative to the viewmodels directory, hence /App/viewmodels/../../dynamic will give you simply /dynamic).</p> <p>By convention, this previous URL (<a href="http://example.com/dynamic/shell/" rel="noreferrer">http://example.com/dynamic/shell/</a>) will be mapped to the controller DynamicController, and the action "Shell".</p> <p>After this, you simply add a controller - DynamicController.cs, like this:</p> <pre><code>// will render dynamic views for Durandal public class DynamicController : Controller { public ActionResult Shell() { return View(); } public ActionResult Home() { return View(); } public ActionResult Nav() { return View(); } public ActionResult Details() { return View(); } public ActionResult Sessions() { return View(); } public ActionResult Footer() { return View(); } } </code></pre> <p>Create .cshtml files for each of the above actions. This way you get to use controllers, server side IoC et al to generate dynamic views for your SPA.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload