0

I'm trying to get my expressJS-Model to my .jade-template, but the way I can access the Model with JS on the client-machine.

The idea is simple: I want to use the Model with Knockout - so I need to give the Model-Object as it is to the client.

If I do the obvious - var t = #{customer} - I ending up with the rendered output var t = [object Object] So how can I use the object on the client-side?

Thanks!

Richard
  • 741
  • 2
  • 7
  • 17
  • found it: http://stackoverflow.com/questions/7681821/passing-objects-to-client-in-node-express-jade – Richard Nov 30 '12 at 11:23

1 Answers1

1

JSON.stringify the object on the server, and JSON.parse it on the client (will only work in IE >= 8, if you need to support older i3-browsers you could provide json-js from douglas crockford: https://github.com/douglascrockford/JSON-js

hereandnow78
  • 14,094
  • 8
  • 42
  • 48