I am new to Angularjs. I am having the form data which I need to make a post request to the server passing the data. I have done the UI and controller part inside the angularjs but do not know how to capture the form data. Please find the link to plnkr - Plnkr link
By clicking the add button, a new li element gets added and the same gets deleted when the minus sign is clicked. I need to get all the key value items into the below format for sending for Post request.
{
"search_params": [
{
"key": "search string",
"predicate": "matches",
"value": "choosen text"
},
{
"key": "search string",
"predicate": "not-matches",
"value": " search value"
},
{
"key": "search string",
"predicate": "matches",
"value": " search value"
}
]
}
How to capture the form data and construct the param object inside my controller inside the searchParams function inside the controller. Please let me know as I am new to Angularjs.
Updated Question Based on the inputs, I am able to get the user details in the controller. But there are few things:
- By default there will be one
lielement and when the user submits, the currentlielements data should be captured in the controller. - Only when I add the criteria using the plus button, the array is getting updated, but the last elements data is not being updated in the model when submitted.
- The same is holding good for the deleting the criteria too.
Link to updated Plunker - Plnkr Link