knockout.js - Regarding the usage of ko.toJSON($data, null, 2) knockout js -
it seems ko.tojson()
convert json string.
<pre data-bind="text: ko.tojson($data, null, 2)"></pre>
but not understand $data
because nevere declared or used in code. see full code here link http://jsfiddle.net/7e0vujf5/11/
why second argument null , meaning of 2nd 3rd argument.
thanks
$data
special knockout binding context variable available inside data-bind
expressions , refers view model object in current context.
the other 2 parameter controls json.stringify()
method called ko.tojson
where null
replacer fuction:
a function alters behavior of stringification process, or array of string , number objects serve whitelist selecting properties of value object included in json string. if value null or not provided, properties of object included in resulting json string.
and 2 space:
a string or number object that's used insert white space output json string readability purposes.
Comments
Post a Comment