Getting knockout.js custom component content -
Getting knockout.js custom component content -
i trying create custom component in knockout.js.
html
<demo-widget>text needed</demo-widget>
javascript
ko.components.register('demo-widget', { template: '<div>new text</div>' }); ko.applybindings();
the component loads fine , everything, want able content within original custom component tag(example "text needed" text).
any thought how can this? hope explained enough.
here fiddle: http://jsfiddle.net/whesleybarnard/f7bmynp5/5/
why not utilize params attribute save initial text:
html:<demo-widget params="initialvalue: 'text need get...'"></demo-widget>
js: ko.components.register('demo-widget', { template: "<div data-bind=\"text: 'content in component. previous was: ' + initialvalue \"> </div>" }); ko.applybindings();
knockout.js knockout-components
Comments
Post a Comment