Background:
I spent a lot of time to debug this knockout js error as the title shows, and finally I found the cause which made me kind of angry because it was not worth wasting so much time on it.
Lesson I learned:
Always write the html tags as the basic form.
Problem:
Met a javascript error thrown when applying knockout binding to page:
Uncaught Error: Cannot find closing comment tag to match: ko if: ***
Cause:
Wrote some html tags in a space-saving format. For example:
<select data-bind="options: DurationList, optionsValue: 'Value', optionsText: 'Text', value: $parent.MonthDuration" />
Solution:
Write the tags in the basic form manner. Take the above html tag for example, write it in this way:
<select data-bind="options: DurationList, optionsValue: 'Value', optionsText: 'Text', value: $parent.MonthDuration"></select>