var mapping = {
'observe': ["testProperty"]
}
var viewModel = ko.mapping.fromJSON(data, mapping);
But this is making all the properties in the viewModel as observable.
var mapping = {
'observe': ["testProperty"]
}
var viewModel = ko.mapping.fromJSON(data, mapping);
But this is making all the properties in the viewModel as observable.
Yes we can do this by using copy
which is straight from Ko Doc's here
Ignoring certain properties being observables using “copy”
If you want the mapping plugin to simply copy the plain properties and not make them observable, use this argument, as shown below.
// tell the mapping plugin to handle all other properties normally, but to simply copy this property instead of making it observable
var mapping = {
'copy': ["propertyToCopy"]
}
var viewModel = ko.mapping.fromJS(data, mapping);
I suggest you to go through this wonderful post here
Working fiddle here explaining the case