I have a component named 'my-component':
ko.components.register('my-component', {
viewModel: function() {
return { title: 'title' };
},
template: '<div>x</div>'
});
I'm using this component in the view like that:
<my-component params=""></my-component>
Is there any way to get the component's view-model related to this HTML node? ko.dataFor doesn't work:
ko.dataFor($('my-component').get(0)) // it doesn't return component's view model
Any thoughts?
Try this: