http://stackoverflow.com/questions/42303187/pass-observable-to-component-through-component
HTML
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.1/knockout-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout.mapping/2.4.1/knockout.mapping.min.js"></script>
<div>
<view-model></view-model>
</div>
JavaScript
ko.components.register('view-model', {
viewModel: function(){
this.myParameter = ko.observable("Topst");
},
template:
'<div style="border: 1px solid blue; width:600px; margin:auto; padding: 32px; text-align:center;">\
<h3>\
Main Component\
</h3>\
<view-model2 params="{ data: $data.myParameter}"></view-model2>\
</div>'
});
ko.components.register('view-model2', {
viewModel: function(params){
var self = this;
self.myObservable = params.data;
return this;
},
template:
'<div style="border: 1px solid blue; margin:auto; padding: 32px; text-align:center;">\
<h3>\
Child Component\
</h3>\
<span data-bind="text: myObservable"></span>\
</div>'
});
ko.applyBindings();