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,
- producteditor_admin.html
- producteditor_superviser.html (instead of these 2 views, used have producteditor.html, convention worked)
and single viewmodel:
- 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
Post a Comment