Connect the value of the input field to the dataset

In my current project, I am implementing ng-repeat to showcase a collection of items. Each item includes a line number, an HTML input field for quantity input, and an itemId. I am currently exploring ways to connect the input value with the quantity field in the myItem object.

<tr ng-repeat="myItem in selectedItems track by $index">
<td>
    {{ myItem.lineNumber }}.
</td>
<td>
    <input type="text" size="8" ng-blur="showAllItems()" ng-bind="myItem.qty" ></input>
</td>
<td>
    {{ myItem.itemId }}
</td>
</tr>

One observation is that I am using the ng-blur method to trigger the display of all items. Here is the code snippet for this method:

$scope.showAllItems = function() {

angular.forEach($scope.selectedItems, function(value,key) {
    console.log("key = " + key + ", value.lineNumber = " + value.lineNumber + ", value.qty = " + value.qty + ", itemId = " + value.itemId);

});

}

Upon analyzing the output, I noticed that the qty value is not synchronizing correctly with the dataset. Can anyone offer insights on what could be causing this issue?

Appreciate your help!

Answer №1

ngModel holds the solution:

<input type="text" size="8" ng-blur="showAllItems()" ng-model="myItem.qty" />

Answer №2

In order to track the quantity of an item, make sure to include the ngModel attribute with ng-model="myItem.qty"

Answer №3

Appreciate the help everyone, problem solved! Turns out I needed to switch from using ng-bind to ng-model.

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

Align the center of table headers in JavaScript

I'm currently in the process of creating a table with the following code snippet: const table = document.createElement('table'); table.style.textAlign = 'center'; table.setAttribute('border', '2'); const thead ...

Retrieving JSON data from a URL with PHP

Attempting to retrieve JSON data from the following URL: $search_data&format=json&nojsoncallback=1 The information I am aiming to obtain based on the above link is as follows: { "places": { "place": [ { ...

How to pass parameters in the URL using AngularJS UI Router

In my config.js file, I have a state defined as follows: state("link_redirect", { url: "/link-redirect/", controller: "LinkRedirectCtrl", title: "Redirect Link", params: {endpoint ...

Building on the Vuejs3 and Vuex4 framework, create a conditional rendering feature that triggers upon

I have a unique setup where custom objects are used to hold child objects full of data. The child objects start with null values for all properties, allowing them to be filled with data from remote sources when referenced. This results in a lazy-loading sy ...

Troubleshooting issues with the delete functionality in a NodeJS CRUD API

I've been struggling to implement the Delete functionality in my nodejs CRUD API for the past couple of days, but I just can't seem to get it right. As I'm still learning, there might be a small detail that I'm overlooking causing this ...

Leverage the power of Next.js Dynamic routing query object with an SWR fetch request

While working with Next.js dynamic routing, I am facing an issue where my SWR fetch request is being called before the query object is properly set. This occurs specifically when using the routing query object. Let's take the example of a dynamic rou ...

Unable to transform dynamically loaded text area into CKEditor

Executing the get_content function upon a link click. function get_content(n) { var hr=new XMLHttpRequest(); var url="./updatecontent.php"; var vars="id="+n; hr.open("POST",url,true); hr.setRequestHeader("Content-type","application/x-w ...

Exploring the power of QueryTask in ArcGIS JS API 3 for running multiple queries

When using QueryTask in ArcGIS JS Api 3, I encountered a challenge where I needed to execute multiple queries in one call. After referencing the documentation, I realized that this functionality was not directly supported. This is my current implementatio ...

Guide on sending a model to a Bootstrap modal from an MVC controller

After spending some time on this project, I believe I am getting close to a solution. My goal is to edit MVC application users using a Bootstrap modal and Angular for binding. I have set up a function in Angular to handle editing a user by passing their ID ...

What is the best way to execute a function after a successful Stripe payment in an Angular application

For my project, I need to integrate the Stripe payment gateway. I am looking for assistance in calling the API function "orderStatusUpdate" after a successful payment by the customer. Can anyone help me with this? loadStripe() { if(!window.document. ...

Is the variable leaping to a superior scope?

A few days back, I encountered a strange bug in my code that has left me puzzled. It appears that a variable declared within a narrower scope is somehow leaking into a broader one. Any insights into what might be going wrong here? Here's a simplified ...

Puppeteer Alert: Unable to Locate Node for specified selector

When using Puppeteer to interact with an input element on a requested URL, I encountered an issue. First, I entered a quantity like this: await page.type('#bidamount_temp', bidAmount); However, when trying to click on the following button after ...

Horizontally position the main word from the D3-WordCloud in the center

I am working on a WordCloud project and have utilized code from Jason Davies D3-JavaScript-WordCloud Example, which can be found at this link. The majority of the code I have used is from a helpful tutorial in German by Lars Ebert, available at this URL. ...

Use Angular2 to showcase the selected image as the main one when the user clicks on the

I'm working on creating a product thumbnail gallery, and I'd like the main image to be displayed when the user clicks on a thumbnail. I am using Angular for this project, although I am still learning my way around the framework. product.html &l ...

Implementing route navigation in two components using a click button

To display the content of the Quiz component with the path "/quiz" after clicking a button and fetching the component with the path "/" is my goal. Here is the code snippet from the App.jsx file: <Router> <Routes> <Route ...

Struggling with jquery's addClass method when trying to apply a class to

Below is a sample tr: <tr> <td><input type="text" class="ingredient required" name="ingredient"></td> <td><input type="number" class="amount required" name="amount" ></td> <td><input type="number" c ...

Click once to open the JS menu, and click again to be redirected to the URL

I am attempting to design a dropdown menu that will reveal the child elements upon first click. When clicking on a child element, it should navigate to the child's URL. Clicking on the country name again should collapse the child menu. Although I hav ...

Is Angular File API Support Compatible with HTML5?

When checking for HTML5 File API browser support in my code: private hasHtml5FileApiSupport; constructor(@Optional() @Inject(DOCUMENT) document: Document) { const w = document.defaultView; this.hasHtml5FileApiSupport = w.File && w.FileReader & ...

Getting the WatchPosition update just one time

I have implemented this code to continuously retrieve the first position and I need it to keep doing so. var init = function() { navigator.geolocation.getCurrentPosition(function(position) { new_position = position; }, onEr ...

Preventing pageup/pagedown in Vuetify slider: Tips and tricks

I am currently using Vuetify 2.6 and have integrated a v-slider into my project. Whenever the user interacts with this slider, it gains focus. However, I have assigned PageUp and PageDown keys to other functions on the page and would like them to continue ...