A really short post, but this little template insert for knockout is incredibly useful when you’re not sure what’s going on inside your view model:
1 2 3 |
<div class="clear"> <pre data-bind="text: ko.toJSON($data, null, 2)" /> </div> |
This snippet essentially outputs the contents of your view model as text on to your page. What I like to do with things like this is add them to a Resharper live template – for me, whenever I’m inside my cshtml file, I just type “kodebug” and I get the above snippet. Sometimes the simplest things are the most useful!!