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

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -