Wednesday, April 17, 2013

Generate Knockout Viewmodels using T4 templates


When developing JSON-only web apps (or mixed web apps) and you're using Knockout to bind your JavaScript models to the UI, you will have noticed how tedious the translation from .NET classes to Knockout models is. This article describes a solution to this problem by using T4 templates to generate the JavaScript Knockout models automatically based on the .NET classes. The resulting Knockout models are extendable so as to be able to add additional functions and (computed) properties client-side. Finally, I also added an IsDirty feature that can indicate if the model has been modified since it's data was set.


I guess you came to this post by searching similar kind of issues in any of the search engine and hope that this resolved your problem. If you find this tips useful, just drop a line below and share the link to others and who knows they might find it useful too.

Stay tuned to my blogtwitter or facebook to read more articles, tutorials, news, tips & tricks on various technology fields. Also Subscribe to our Newsletter with your Email ID to keep you updated on latest posts. We will send newsletter to your registered email address. We will not share your email address to anybody as we respect privacy.


This article is related to

</ span>Knockout, T4 Templates, Knockout Viewmodels

LinkWithin

LinkWithin

Like Us On Facebook and Receive All Updates!

You can also receive Free Email Updates:

Powered By Tutorails