javascript - HotTowel Durandal Inject different views based on the user -


in shell.html hottowel template have:

    <!--ko compose: {model: router.activeitem,          aftercompose: router.aftercompose,          transition: 'entrance'} -->     <!--/ko--> 

which automatically insert proper view convention. trying inject different views based on user's role in hottowel/durandal app. example, have 2 views,

  1. producteditor_admin.html
  2. producteditor_superviser.html (instead of these 2 views, used have producteditor.html, convention worked)

and single viewmodel:

  1. producteditor.js

now, want have function in producteditor.js let me decide view insert based on user's role. see in composition documentation, can function strategy(settings) : promise not sure what's best way accomplish in hottowel template. have tried , got answer that?

it's possible return 'viewurl' property in view model, following crack door open ;-).

define(function () {     viewurl = function () {         var role = 'role2'; //hardcoded demo          var roleviewmap = {             'default': 'samples/viewcomposition/dfiddle/index.html',             role1: 'samples/viewcomposition/dfiddle/role1.html',             role2: 'samples/viewcomposition/dfiddle/role2.html'         };          return roleviewmap[role];      }      return {         viewurl: viewurl(),         propertyone: 'this databound property root context.',         propertytwo: 'this property demonstrates binding contexts flow through composed views.'     }; }); 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -