Is it possible to use ng-click to pass multiple arrays at once?

I am working with a nested JSON object array and successfully displaying Inner Items grouped by Info in HTML using ng-repeat. Each Inner Item has a checkbox with an ng-click event handler that passes the selected Inner Items to the controller. However, I now want to also pass the Info id in the ng-click event. Is there a way to concatenate the Info array to the Inner items array in the ng-click?

Here is the structured JSON data:

[
  {
    "Info": {
      "id": "a1",
      "name": "a1-Info",
      "InnerInfo": [
        {
          "name": "xyz"
        }
      ]
    },
    "InnerItems": [ 
      { "id": "i1" }, 
      { "id": "i2" } 
    ] 
  } 
]

<tr ng-repeat=“I in MyData">
<td> {{I.Info.name}}
      <table>
             <tr><td>
                 <div ng-repeat=“item in I.InnerItems ">
                       <input type="checkbox" name="values" ng-click=“getInfo(I);getInnerItems(item)” ng-true-value="1" ng-false-value="0"/>{{item.name}}
                 </div>
                 </td>
             </tr>
       </table>
  </td>
  </tr>

Instead of the current method, I am looking for suggestions on how to pass both arrays to one function. Any ideas?

Answer №1

Implementing an expression containing ng-click to assign a value to the controller.

Assuming there is a property named activeData on the controller, you can utilize ng-click in the following manner:

ng-click="activeData = [I , item]"

Answer №2

By passing multiple parameters directly to the getInfo function, such as getInfo (I, items), I was able to successfully access them in the controller without the need for using any properties. Everything functioned smoothly.

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

Find the Time Difference in IST using JavaScript

Is there a way to calculate the time difference between two different time zones in javascript? var startTime = doc.data().startTime; output: Fri Dec 06 2019 19:00:00 GMT+0530 (India Standard Time) var currentTime = new Date(Date.now()).toString(); outpu ...

The present IP address of the client through AJAX and PHP

This code snippet is on my PHP page: // Setting the timezone to Asia/Manila date_default_timezone_set('Asia/Manila'); $date = date('m/d/Y h:i:s a', time()); if (!empty($_SERVER['HTTP_CLIENT_IP'])){ $ip=$_SERVER['HTTP_C ...

Leveraging the ng-model value in ng-if

I am currently working on a feature that involves checking if an entered idNumber exists in a table, and then adding a glyphicon to the corresponding row. One issue I am facing is figuring out how to access the ng-model="idNumber" from within ng-if. My a ...

React and Material-Ui utilize class definitions in .js files, which are then passed as strings to components

I am attempting to define a class within my .js file in order to utilize the material-ui theme object and pass it as a string to a component since the component's prop only accepts strings. Unfortunately, the React-Dropzone import does not accept a cl ...

What is the best way to transfer weather data from a server to an HTML text area box?

Recently, I delved into the world of expressJS to set up a local server (localhost:3000). With the power of JavaScript (specifically in a file named app.js), I was able to send simple messages like "Hello World" to the browser. However, now I find myself f ...

Different kinds of garbage collection operations in NodeJS

When utilizing the perf_hooks module in NodeJS, we have access to information regarding garbage collection. This can be achieved by using PerformanceObserver, which is triggered with each garbage collect event. const obs = new perf_hooks.Performanc ...

Comparing data in Knockout js

I'm trying to compare the values of the variable name by id, but I'm not sure how to do it. Here is what I have so far: if (this.name == self.copy().indexOf(this.id).name) { alert('equals'); } else { alert('not equals&apo ...

Upon sending a POST request, an UnhandledPromiseRejectionWarning was triggered due to an unhandled promise

Whenever I try to make a post request, I keep encountering this particular error message: UnhandledPromiseRejectionWarning: Unhandled promise rejection. If anyone out there can shed some light on why this issue is occurring, I would be extremely grateful ...

jQuery uploads elements only when the page is initially loaded for the first time

The issue seems to be related to the $(document).ready(function() {}); code block or potential misuse of callbacks. My goal is to execute getTotalMarketCap(), getAllOtherValues(), and getMarketShare() in sequence for an accurate market share calculation. ...

steps to invoke a class within a function

I'm currently attempting to invoke a model class from the Axios response. Instead of displaying an alert, I would like to show a modal popup. Can someone assist me with how to call the modal class from the Axios interceptor function? Thank you in adva ...

Ways to streamline data consolidation in AngularJS when dealing with multiple identical items

New to the world of Angular, I'm looking to combine items with the same names from an array. $scope.items_list = [{name: 'cars',quantity: 2}, {name: 'cars', quantity: 4}, {name: 'cars', quantity: 5},{name: 'truck ...

Is there a way to select multiple elements with the same class using getElementByClassName instead of only obtaining the first element with that class designation?

I recently started learning JavaScript, and I'm still struggling to grasp many concepts. I'm currently working on styling buttons on my website to match the existing ones, but I'm unable to edit the plugin's HTML directly. I was able to ...

Comparing the positions of elements in Selenium WebDriver with PHP

One of the elements on my webpage serves as a button that reveals a drop-down menu. Due to various factors affecting the page layout, there were some alignment issues between the button and the menu until a few bugs were fixed. I am now looking for a way t ...

Tips for selecting 'module' over 'main' in package.json

I have developed several npm modules and compiled them in two ways: commonJS (using exports.default =) and esm (using export default) In my package.json, I have specified the main file as index.cjs.js and the module file as index.esm.js. However, when ...

Infura makes ten calls to eth_getBlockByNumber for every eth_call request

Currently, I am in the process of creating a straightforward nextjs API route (https://nextjs.org/docs/api-routes/introduction) that is linked to the Ethereum blockchain for executing a view function (which doesn't require any gas) from a smart contra ...

Using ServiceStack to deserialize an array

My goal is to post the following data to my ServiceStack web service: $.ajax({ url: 'http://localhost:8092/profiles', type:'POST', data: { FirstName : "John", LastName : "Doe", Categories : [ "Catego ...

What issues can be identified in this ajax.js script?

This particular function is designed to verify the existence or availability of a user login, yet even when the user database table is empty, the form consistently indicates that there is a duplicate entry. As a result, the submit button disappears. What c ...

Mapping memory for FirefoxOS is like equivalent strides

Is there a way to create a memory mapped file in FirefoxOS, Tizen or other pure-JS mobile solutions? In the scenario of a mobile browser where you have large amounts of data that can't fit in RAM or you prefer not to load it all at once to conserve R ...

I have a requirement in my Angular application where I need to display two columns, however, the content within those columns may differ based on the route. What is the best approach to

I have a requirement in my app where I always need two columns, with one being slightly smaller than the other. Currently, each of my routes directs to a different component which provides the markup for these columns in its own template. However, since th ...

The div height adjustment peculiarities in IE7 and IE8 are causing quite a stir

I recently encountered a problem with my HTML/JS code that I thought was simple. The code is designed to expand the size of a div on mouseover and then collapse it back on mouseout. Here's how the code looks: CSS: .sign-in-up { position: absolut ...