Serialize IContent to use in Angular like front technologies
(A self note) A generic service to convert IContent into an Expando Object, ExpandoObject can be converted into JSON to use in Angular/React components.
Find the code gist https://gist.github.com/khurramkhang/e8d4b9ef093fe30610be986efa352744
Limitations:
Find the code gist https://gist.github.com/khurramkhang/e8d4b9ef093fe30610be986efa352744
Limitations:
- not supporting multilingual
- not preparing friendly urls
I doubt that's something you want to do. Now you're basically taking the model from the database and sending it out to the frontend. Rather, make the viewmodels serializable and populate them with whatever you need. You can of course make generic viewmodelfactories etc, but just serializing the content model is probably not the right way.
ReplyDeleteI appreciate your input and agreed, It all depends on requirements. I just shared my experience, love It or loath It :)
Delete