I am having a little bit of trouble creating my Angular 2 form and converting the submitted data into JSON format for the use of submitting it to my API. I am looking for something that works very similarly to this example:
$.fn.serializeObject = function()
http://jsfiddle.net/sxGtM/3/
The only problem with this example is that the code is written in JQuery, whereas I'm trying to use strictly angular 2.
Any help would be greatly appreciated, I am still very new to angular.
相关问题
- Angular RxJS mergeMap types
- Jackson Deserialization not calling deserialize on
- Laravel Option Select - Default Issue
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
相关文章
- angular脚手架在ie9+下兼容问题
- angular 前端项目 build 报错 "Cannot find module 'le
- json_encode 没有把数组转为json
- Angular Material Stepper causes mat-formfield to v
- Livy Server: return a dataframe as JSON?
- After upgrade to Angular 9 cannot find variable in
- is there any difference between import { Observabl
- Suppress “Circular dependency detected” suppress w
You can use the
getRawValue()
function if you're using aFormGroup
, to return an object that can then be serialized usingJSON.stringify()
.You are looking for
JSON.stringify(object)
which will give you the JSON represantation of your javascript object.You can then POST this using the built-in HTTP service to your server.
You can use
JSON.stringify(form.value)
:Result in Chrome DevTools: