knockout.js - Is it possible to inject values from the KO view model to a template? -
would understand whether it's possible inject values view model in template out using "data-bind" using knockout js.
for example, if have following view model;
var myviewmodel = { var self = this; self.firstname = ko.observable("abc"); self.lastname = ko.observable("xyz"); };
i need create template following;
<script id="myinjecttemplate" type="text/html"> <h3 id="header_${firstname}">${firstname} - ${lastname}</h3> </script>
where inject values in view model place holders, in apache velocity ?
thanks.
you can set id using data binding too, know, can both:
<h3 data-bind="attr: { id: 'header_$' + firstname() }, text: firstname() + ' - ' + lastname()"></h3>
though i'd @ using computed observable create full name first , last name observables.
Comments
Post a Comment