First determine how you want to decode html strings. There are a bunch of options listed here: HTML Entity Decode
Assuming you have a global function called decodeEntities
available, you can provide a computed property that simply performs this decoding over myHtml.
var ViewModel = function() {
this.myHtml = "<h1>hello</h1>";
this.decodedHtml = ko.computed(function(){
return decodeEntities(this.myHtml);
});
};
Please be aware that since myHtml is not an observable, decodedHtml will always resolve to the same value and never trigger updates (unless manually enforced), no matter what value you assign to myHtml afterwards.
Alternative ways of achieving the same results are to either decode myHtml inline or create a custom binding that does decoding on the spot.