2012-10-13 10 views
0
내가 JSON 문자열에 저장되지 않는 'B'원하는
<div data-bind='a'></div> 
<div data-bind='b'></div> 
<pre data-bind="text: ko.toJSON($root, null, 2)"></pre> 

..<a href="http://knockoutjs.com/documentation/plugins-mapping.html" rel="nofollow">mapping</a> 코 플러그인을 사용

+0

많은 방법이 있습니다. ''ko.toJSON ($ root, [ 'a'], 2)'도 할 수 있습니다. 다른 옵션에 대해서는 18:12에 동영상을 참조하십시오. https://vimeo.com/51103092 –

답변

0

HTML 페이지의 데이터 바인더 제본 사용 knockout.js에서 JSON 문자열로 갈 요소를 생략하는 방법 :

<div data-bind='text: a'></div> 
<div data-bind='text: b'></div> 
<pre data-bind="text: ko.mapping.toJSON($root, {ignore: ['b']})"></pre>​ 
관련 문제