Accessing properties in JSON data with AngularJS

I am experiencing issues with accessing a JSON object returned from an $http call in my AngularJS app. I have provided the code snippet below, but it seems that nothing is being rendered on the HTML. Can anyone please assist me in identifying what I might be doing wrong and guide me on how to correctly access the properties of the JSON object? Your help will be highly appreciated.

Just to note, I confirmed that the data is being sent to the view by utilizing console.log to print the customers list JSON object to the console.

Thank you.

{"Result":
   [{"customer":
        {"CustomerName":"Michael",
         "CustomerId":"212331",
         "Active":true
        },
        "salesid":19,
        "sales_name":"John West",
        "rank":["Sales Manager"]

...
...

In customers-list.html:

    <ul>
        <li ng-repeat="customer in myCustomersList">
            <div>
                <div>
                   <p>Customer Name: {{customer.CustomerName}}</p>
                </div>
            </div>
        </li>
    </ul>               

Answer №1

If the data returned from your $http request, as seen in your initial post, is stored in a variable named data, and you have assigned it to $scope.myCustomersList, then your HTML structure should look like this:

<ul>
    <li ng-repeat="customer in myCustomersList.Result">
        <div>
            <div>
               <p>Customer Name: {{ customer.customer.CustomerName }}</p>
               <p>Sales Name: {{ customer.sales_name }}</p>
               Rank(s): 
               <ul>
                   <li ng-repeat="rank in customer.rank">{{ rank }}</li>
               </ul>
            </div>
        </div>
    </li>
</ul>      

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

Transforming a PHP cURL call to node.js

Currently exploring the possibility of utilizing the Smmry API, however, it seems that they only provide PHP API connection examples. Is there anyone who could assist me in adapting it into a JS request? My requirement is simple - I just need it to analyz ...

Currently, I am in the process of developing a fabric mod, but I am encountering some difficulties with the ClientOnInitialize

When I leave the onInitialize method empty, the public class TutorialModClient appears grey in IntelliJ. All required entries are present in my fabric.mod.json: the json entries are "entrypoints": { "main": [ "n ...

Creating Unique Names for DataMembers in WCF Generics

I currently have a WCF REST / JSON service that provides various types of data lists. I want to enhance each response by adding a revision number attribute. Let's take the example of a 'Car' class [DataContract] public class Car { [Dat ...

Ajax response values overlap

I am developing an application that requires multiple Ajax requests, but I encountered a problem where I am receiving the same response values for both requests. Each request must include a data field called activityCode, yet I keep getting the value of Sc ...

Create a parent dropdown class that contains two separate bootstrap dropdowns nested within it

I am encountering an issue with my dropdown menus. I have 2 dropdown menu items under the same parent dropdown class. However, when I click on dropdown action 1, it displays the body of dropdown menu 2 items instead. <!DOCTYPE html> <html> < ...

An 'Syntax Error' message appears in Internet Explorer when JSONP does not receive a response

Our current application needs to retrieve information from another application, and this second application does not have to be active to respond to the JSONP request. In this case, the requester will receive an alert message informing them of this. funct ...

What is the best way to navigate back to the top of the page once a link has been clicked?

One issue I'm facing is that whenever I click on a link in NextJS, it directs me to the middle of the page: <Link href={`/products/${id}`} key={id}> <a> {/* other components */} </a> </Link> I believe the problem l ...

How to dynamically populate a select option with data from a database in CodeIgniter 3 and automatically display the result in a text

How can I fetch select options from a database in CodeIgniter 3 and display the result in a text field and span area? Currently, I am only able to display data from the row_name when an option is selected. Here is my current implementation: <?php $query ...

Angular: How come my filter only functions properly when implemented in a less efficient manner?

Let's get this done quickly, my dear friends I'm facing an issue with a filter in my code. Interestingly, it doesn't work when I follow the recommended method, but if I use another approach - which is not considered proper - the filter work ...

Navigate through an array of objects to retrieve particular key/value pairs

I have an item that has the following structure: [ { "title": "Job Title", "email": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="385d55595154785d55595154165b5755">[email p ...

Retrieve information from XML using jQuery

<?xml version="1.0" encoding="UTF-8"?> <slider> <csliderData1> <title>Kung Fu Panda</title> <content>In the Valley of Peace, Po the Panda finds himself chosen as the Dragon Warrior despite</content ...

Retrieving the data from an Angular website using a curl command

Currently, I am facing an issue with my Angular 2 application running on Google Earth. The problem arises as Google Earth uses an outdated version of Chrome that is not compatible with Angular 2. To tackle this obstacle, I need to find a way to initiate th ...

Ways to bypass browser pop-up blockers when using the window.open function

I am displaying an HTML retrieved from the backend. printHtml(htmlContent) { var windowToPrint = window.open('', '_blank'); windowToPrint.document.write(htmlContent); setTimeout(function () { windowToPrint.document ...

Dragging items in the horizontal list of Knockout-Sortable causes them to be pushed vertically

For my application development using knockout.js, I am implementing knockout-sortable to create drag-and-drop sortable lists. The setup involves a vertical list with each item containing a horizontal list. While the vertical lists are functioning properly, ...

Reset input fields while retaining placeholder text

Seeking advice on how to use this handy jQuery tool properly: $('.myDiv input').each(function () { $(this).val(""); }); Though it clears my form, I'm struggling to maintain the placeholders of the inputs. Any suggestions? C ...

The CORS policy is preventing the AJAX request from functioning properly on localhost

Recently, I have been working on an Angular application that requires interaction with an API. To test it out, I set up an API on my localhost and made a request using AJAX. However, I encountered the dreaded CORS error. Despite trying various solutions fo ...

Exploring the utilization of org.springframework.kafka.support.serializer.JsonTypeResolver: a closer look at 2

Trying to figure out how to implement the resolve method for Kafka's JsonTypeResolver. Encountering two issues along the way. First, wondering how to register my class so that Kafka will recognize it during deserialization. Secondly, need guidance o ...

Check to see if my Node.js server is running in development or production mode

Lately, I've been facing a tedious task every time I deploy a node.js server to my production server. It involves changing all the IP addresses, DNS settings, usernames, and passwords for my various connections to databases and external APIs. This en ...

Using jQuery to add a class to an input option if its value exists in an array

Looking for a way to dynamically add a class to select option values by comparing them with an array received from an ajax call. HTML <select id="my_id"> <option value="1">1</option> <option value="2">2</option> ...

Discover the method to adjust the position of elements, such as images, using radio buttons

I have an image positioned in a container along with 3 radio buttons. I want to make additional images appear over the main image when specific radio buttons are selected. Each button will trigger different positions for the additional images. So far, thi ...