knockout.js - how can I pass dynamically data to a knockout template binding -
depending on chosen template not want bind articles want assign according viewmodel data myself.
how can that?
<div data-bind="template: { name: gettemplate(), foreach: articles }"></div>
instead of binding foreach articles property. bind foreach computed property returns right viewmodel.
templatedata = ko.computed(function(){ if(this.gettemplate() == 'articlestemplate') return this.articles; if(this.gettemplate() == 'doctemplate') return this.docs; ... }, this)
i hope helps.
Comments
Post a Comment