knockout.js - KnockoutJS Mapping toJS ignore nested keys -
can not ignore nested properties when using tojs in knockoutjs' mapping plugin?
example:
var obj = { "akey": { "anestedkey": "ignore", "anotherkey": "value" } }; console.log(ko.mapping.tojs(obj, { "ignore": ["akey.anestedkey"], })); expected output
{ akey: { anotherkey: "value" } } actual output is
{ akey: { anestedkey: "ignore" anotherkey: "value" } } jsfiddle: http://jsfiddle.net/48kvu/
it works if remove parent (if know key unique in obj or if want remove occurences):
var obj = { "akey": { "anestedkey": "ignore", "anotherkey": "value" } }; console.log(ko.mapping.tojs(obj, { "ignore": ["anestedkey"], //here })); http://jsfiddle.net/gabrieltran/48kvu/1/
knockout.js knockout-mapping-plugin
No comments:
Post a Comment