我有"objectToMyObject"
将对象属性转换为MyObject
属性 的静态方法objectToMyObject
。我正在尝试将“ objectToMyObject
”更改为“ mapping.fromJS(data)
”。但我不能这样决定。主页实现这个问题?
// My get method:
getMyObject(url: string, params: any, onSuccess: () = > {}, onError: (message: string) = > {}) {
this.invokeAjax(url, params, (data) = > {
if (!data.succeeded) {
onError(data.error);
} else {
this.editMyObject(MyObject.objectToMyObject(data));
//this.editMyObject(<any>this.editMyObject((<any>ko).mapping.fromJS(data)));
onSuccess();
}
});
}
// My invoke method:
invokeAjax(url: string, params, callback: (result: any) = > {}) {
$.ajax({
url: url,
type: 'GET',
data: params,
dataType: 'json',
cache: false,
success: (data) = > {
callback(data);
},
error: (data) = > {
this.succeeded(false);
}
});
}