retrieve information and populate the model in the angularjs view

$scope.orderDetails = [
        {
            "id":"115584",
            "user_id":"78937",
            "your_sys_global":null,
            "created_at":"2017-12-08 05:03:20"
        },
        {
            "id":"115585",
            "user_id":"78936",
            "your_sys_global":"MicSamse",
            "created_at":"2017-12-08 05:03:21"
        },
        {
            "id":"115586",
            "user_id":"78938",
            "your_sys_global":null,
            "created_at":"2017-12-08 05:03:52"
        }
    ];

<div ng-repeat="user in profiles track by $index">
    <input
    type="text"
    name="your_sys_global_{{user.user_id}}"
    ng-model="orderDetails[user.user_id].your_sys_global"
    ng-change="saveOrder(user, orderDetails[user.user_id])"
    >
</div>

Could you please provide assistance on why the details are not appearing in the textbox?

Answer №1

The issue lies with orderDetails[user.user_id]; your $scope.orderDetails is an array and requires an index to update a value within that array.

Additionally, using ng-change may not be necessary as ng-model can automatically update your $scope.orderDetails if configured correctly.

To address this, consider adding the following function to your $scope:

$scope.getUserOrder = function(user) {
  return $scope.orderDetails.filter(function(order) {
    return order.user_id === user.user_id;
  })[0];
};

Then, update your HTML markup to utilize this method:

<div ng-repeat="user in profiles track by $index">
    <input
    type="text"
    name="your_sys_global_{{user.user_id}}"
    ng-model="getUserOrder(user).your_sys_global"
    >
</div>

While there may be some minor errors, please overlook them for now.

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

AngularJS dynamic drop-downs with filtered values appearing successively

Is it possible to create cascading drop-down menus where the second drop-down only shows options that partially match the selection from the first drop-down? EXAMPLE: DROPDOWN1: TOOL1 DROPDOWN2: TAGFORTOOL1 TOOL2 TAGFORTO ...

Issues with cross-browser compatibility are arising in my jQuery code

Here is the code snippet I'm working with: function toggleLoader( display ){ if( display === 'show' ){ $('.overlay, .loader').css({ 'z-index' : '1000', 'display& ...

The table is failing to update its data when I attempt to refresh it using the custom button on the page

I need to incorporate a refresh button using an angular material icon on my webpage that triggers an HTTP call to retrieve the latest data and update the view. I have implemented a $watch function to monitor any updates. Below is the corresponding JavaScri ...

What is a clear indication that a <div> is filled with text?

Picture a scenario where a website contains an element that needs to be filled with random text using JavaScript. Once the div is completely filled, it should reset and begin again. It may sound odd, but the question is: how will the JavaScript determine w ...

The scrolling speed of Ionic Load More feature is a bit sluggish

Hey there! I'm a newcomer to Ionic and AngularJS. In my current project with Ionic v1, the load more scrolling feature is extremely sluggish. I've attempted two different methods: Using a Service Using a Factory Both approaches are proving t ...

Utilize JavaScript or jQuery to convert XML into a string representation

Is there a way to convert XML data into a string based on user input in JavaScript or jQuery? The XML file can be found at rssfeed.ucoz.com/rssfeed.xml and is too large to include here. For example: Original XML <item> <title>Abyssal Wa ...

A JavaScript async function that can be activated either by clicking the search button or by hitting the "enter" key in the input field

Recently, I've been working on an async function in Vanilla Javascript that is triggered by a click event on the search button. However, I would like to modify it so that the function can also be initiated when the "enter" key on the keyboard is press ...

Entering destinations into the Google Maps search bar

I am currently working on a project that involves creating a Google Maps window. The goal is for the user to input their location (marker A) and receive directions to a specified destination (marker B), ideally using an input box and submit button. So far, ...

Button activated on second click

As I am working on a project, I encountered an issue with two buttons and one input field. The input field is supposed to take the value of the clicked button, but currently, the function works only after the second click on the button. I have tried using ...

My AngularJS ng-show functionality is not functioning as expected. I have already reviewed the syntax and still encountering issues

Having trouble with my ng-show, it's not functioning as expected <div class="form-group"> <label class="control-label col-sm-4">NotesTest:</label> <div class="col-sm-4"> <textarea class="form-control ...

"Enhance performance in React by optimizing the re-render of nested functional list components

Is it expected for the custom component CheckboxLabels to not retrieve a different checked prop after each invocation of the handleCheckboxChange function? Currently, I am unable to update the state of the clicked checkbox to be "checked" before closing ...

Retrieve the smallest value from an array of objects using BitGO

Bitgo stores all transactions as objects within a large array. Within the nested .entries, we can identify that the first TX object contains two negative values -312084680 and -4254539, of which I only require the lowest value. My current code successfully ...

Positioning a Material UI Menu item underneath its parent element using CSS styling

I have created a Material UI dialog that features some text and an Icon with a dropdown menu option. You can check out the demo here: https://codesandbox.io/s/prod-rain-1rwhf?file=/src/App.js My goal is to properly position the Menu component so that it a ...

obtain or retrieve a data file from the server

I am working with JSON data received from the backend in a specific format. { id: 2 name: dream file file : /home/bakcend/go/uploads/173ba017f27b69b42d7e747.png //backend path } Currently, files uploaded from the front end are stored in a separate dir ...

Having trouble connecting and establishing an onmousemove event?

I am looking to implement a mouse move event handler in my three.js project, but I have been struggling to connect it with the mouse and make it work. It would be greatly appreciated if someone could provide guidance on how to achieve this. I am not sure ...

The React Bit Dev module is showing a 404 error

Attempting to incorporate the semantic-ui-react table reusable component from the Bit.dev community into my application. The link I am using is: To add this component to your application, use: npm i @bit/semantic-org.semantic-ui-react.table However, when ...

What are some ways to reduce the delay of Dark mode on a website?

Can anyone help me optimize the speed at which dark mode is applied on my website? Currently, there seems to be a delay between page load and the dark mode taking effect. Below is the jQuery.js code I am using: onload = function () { if (localStorage. ...

Exploring route grouping with angular ui-router

Is it possible to group routes in ui-router? Consider the following routes in my app: #/products/p1 #/products/p2 #/products/p3 One way to define states is as follows: .state('products.p1') .state('products.p2') .state('product ...

Is there a way to dynamically refresh the Bing web API search results on a React.js application after entering a search query in the search bar (in the SER

I've been using the Bing Web Search API to access data by typing a query into a search bar I created. However, I've been facing an issue where the data isn't displaying in the search results when I submit the query. I'm specifically try ...

Sorting of dates in mui-datatables is not accurate

I have dates that are formatted using moment.js, for example ("Sat, Feb 22, 2020 12:55 PM") I retrieve them from firestore, and they appear to come in correctly as I first sort them in descending order. forms.sort(function(left, right) { return moment.u ...