sending data from an AngularJS application to an MVC controller in JSON format containing multiple arrays

Currently, I am working on a project that involves using AngularJS and MVC. I am transferring data from an AngularJS controller to my MVC controller using $http.post(). At the moment, I am using a single object or JSON array to retrieve data as follows: public bool UpdateIssueDetails(IssueBO issue). However, I am interested in being able to pass two JSON arrays from my AngularJS controller to the MVC controller method by modifying it like this: public bool UpdateIssueDetails(IssueBO issue, List lstMembersToNotify).

AngularJS Controller Code

 Sample code provided here...

MVC Controller Code

 Sample code provided here...

I attempted to pass two JSON arrays from my AngularJS controller using $http.post(url, [issueDetails, arrMembersToNotifyNew]), but encountered an error. Can anyone suggest how I can achieve this successfully? Thank you.

Answer №1

To successfully send information to the function, utilize the JSON.stringify() method.

$http.post(url, JSON.stringify({ problem: problemDetails, 
     listRecipients: newRecipientsArray 
});

Answer №2

Submit the information as attributes of a specific entity.

$http.post(url, { problem: problemDetails, listMembersToAlert: arrayMembersToNotifyNew });

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Numerous CSS/JS Dropdown Menus

I am seeking the ability to implement a dropdown through CSS in various locations within my HTML prototype. This implies that I require the capability to position multiple dropdowns anywhere on the page. Currently, I utilize this method to generate a sing ...

What is the best method for converting a modified array back to JSON format?

I'm currently working on a Discord bot that allows users to use the command tcp freeitem to receive a free item. My goal is to update the Account object by adding a new item to the account. However, when I attempt to map the array to replace a value, ...

In Snowflake, SQL error handling block fails to execute

Implementing error handling in Snowflake using a Try Catch block has been my focus. I've enclosed SQL queries within JavaScript for this purpose. However, upon executing the query, I noticed that it skips the Try Catch block and directly executes the ...

The Vue component should trigger the display of data in a Bootstrap modal based on the row of the button that was

Here is a sample code snippet demonstrating how data is fetched from the database: <table class="table table-bordered"> <thead> <tr><th>User ID</th><th>Account Number</th><th>Accou ...

"The error message "Node JS, MYSQL connection.query is not a valid method" indicates

db_config.js: const mysql = require('mysql'); var connection = mysql.createConnection({ host: 'localhost', user: 'root', password: '', database: 'test' }) connection.connect(function(err) ...

Utilize data attributes for streamlined markup efficiency

I'm facing a challenge with two almost identical animations, the only difference being the positioning of "left vs right". I want to find a way to reuse the same block of code for both .forward and .backward. I have considered using HTML 5 data-attrib ...

What is the method for incorporating an item into a JsonObject entity as one of its properties?

Currently, this is my approach: JsonObject jobj = new JsonObject(); jobj.addProperty("name", "awesome car"); I am attempting to include another property with an object as its value like so: jobj.addProperty("car", ANOTHER_CAR_OBJECT); Unfortunately, it ...

Error encountered in 11ty: Invalid operation - eleventyConfig.addPassthroughCopy is not a recognized function

Attempting to integrate my CSS and JavaScript codes into 11ty has been a bit challenging for me. I recently discovered that 11ty utilizes something called .11ty.js, so I decided to utilize the addPassthroughCopy() function. Below is the script I tried: mo ...

Crafting a template for mixing up images and quotes without any specific connection - here's how!

I came across some interesting templates that can generate random quotes and others that create random pictures. My goal is to develop a template that generates both a random quote and a random picture, similar to this example, without any relation betwee ...

An unresolved $httpBackend in Angular's unit testing environment without a defined response

I'm currently facing some difficulties with my first test, so I would appreciate your understanding. The purpose of this test is to evaluate a function that performs an HTTP post request: $scope.formData= 'client=' + $scope.client_selected ...

Adjusting the size of Bootstrap alerts while ensuring the close icon remains correctly positioned

Below is the HTML code snippet I am working with: <div class="row mt-2"> <div class="col-lg-5"> <div id="alertmessages"></div> </div> <div class="col-lg-7"> <div class="btn-group-sm"> ...

My VW controller is receiving null from AJAX

Hey there, I've been dealing with this issue for a few hours now and still haven't found a solution. All my request data looks good except for subscriptionTag, as it always comes back as null when the request is sent to the server. I even tried ...

Is there a way to transfer innerHTML to an onClick function in Typescript?

My goal is to pass the content of the Square element as innerHTML to the onClick function. I've attempted passing just i, but it always ends up being 100. Is there a way to only pass i when it matches the value going into the Square, or can the innerH ...

What is the reason for this basic callback running before the setTimeout function?

Interesting behavior is observed in this code, where 'output 2' is logged before 'output 1' due to the setTimeout function. const func1 = () => { setTimeout(() => { console.log('output 1'); }, 3000); }; con ...

What is the purpose of using route('next') within ExpressJS?

In the documentation it states: You can have multiple callback functions that act as middleware and can invoke next('route') to skip the remaining route callbacks. This is useful for setting pre-conditions on a route and then passing control t ...

Rendering an Angular page with data using Node.js

I have a scenario for my website where users need to input a URL with a parameter (an ID) and receive back the corresponding page containing information from the database. I am using Angular4 but I am unsure of how to achieve this. It's straightforwa ...

Every time a user clicks on the map, Leaflet automatically adjusts the center

Currently, I am utilizing leaflet within Vue.js to display an image. I have incorporated custom features such as draggable boxes on the map that can be transformed into rectangle leaflet objects by leaflet. My objective is to be able to click on a rectang ...

Binding Data to Arrays in Polymer

I'm currently diving into the world of Polymer. My goal is to connect an array with my user interface in a way that allows for dynamic updates. Each object within the array contains a changing property, and I want my UI to reflect these changes accord ...

Radio button triggers an ajax call once, but then fails to function

How can I troubleshoot an issue where the ajax function only works once when clicking on a radio button to change its value from 0 to 1, but not back to 0? The form contains a table with radio buttons for each record, and clicking on them triggers the aj ...

What are the steps to design a versatile gallery page that can serve various projects?

Allow me to get straight to the point. What is my goal? I am aiming to develop galleries for various projects. Each project's thumbnail on the main page should open a gallery as a new page. These galleries will all have the same layout but different ...