I am rendering a template that accepts an observable array and inside, it uses an inner template to render the content of a property as input text. If I directly render input text in the "foreach" in the parent then any changes to the text are two-way binding and reflected in the related observable array item property but when using the inner template it becomes one way.
--========== Parent template =======--
<div class="skill-rating-section" data-bind="foreach: { data: skills, as: 'skill' }">
<div class="col-comment">
**<!-- This works fine - two way bdinding -->**
<input type="text" data-bind="value:skill.Comment" />
**<!-- This renders the content but is not two way binding -->**
<skill-rating-comment params="viewModel:skill"></skill-rating-comment>
</div>
</div>
--===== Html for inner template(SkilRatingCommentTemplate.html)====
<input type="text" data-bind="value:comment" />
--======= Js code for inner template ================
define('SkillRating/Component/SkilRatingCommentComponent', ['knockout'], function (ko) {
function skillRatingCommentViewModel(params) {
var me = this;
me.comment = params.viewModel.Comment;
return me;
}
ko.components.register('skill-rating-comment', {
viewModel: skillRatingCommentViewModel,
template: {
require: 'text!../../Content/HtmlTemplate/SkillAssessmentComponent/SkilRatingCommentTemplate.html'
}
});
});