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!

4

1 回答 1

1

JSON.stringify服务器上的对象,并JSON.parse它在客户端(仅适用于 IE >= 8,如果您需要支持较旧的 i3 浏览器,您可以提供来自 douglas crockford 的 json-js:https:// github.com/douglascrockford/JSON-js

于 2012-11-30T10:54:57.897 回答