After implementing the ng-repeat directive, the div element vanishes

I've been working on fetching data from a Json API and displaying it on user event. However, I'm facing an issue where the div disappears whenever I apply the ng-repeat property to it. Despite searching through various tutorials and documentation, I haven't been able to find a solution. Please assist me. Thank you.

My HTML:

    <!DOCTYPE html>
<html ng-app="myApp">
<head>
    <link rel="icon" type="image/png" href="images/logo.png">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Football News</title>

    <link href="https://fonts.googleapis.com/css?family=Dosis" rel="stylesheet"> 


    <!--AngularJs CDN-->
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.6/angular.min.js"></script>

    <link rel="stylesheet" type="text/css" href="Css/home.css">
</head>
<body>
    <div class="container" ng-controller="homeController as home" ng-init="home.loadAllMatches()">
        <div class="mainContent">
            <div class="header">
                <span>Primier League</span>
            </div>
            <div class="content">
                <div class="matchList" ng-repeat="round in home.rounds">
                    <div class="matchListContent" ng-repeat=" match in round.matches"> 
                        <span>{{ match.name }}</span>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="angular/Controller/mainController.js"></script>
</body>
</html>

My JS:

 var footballApp = angular.module('myApp', []);

footballApp.controller('homeController',['$http', function($http){
    var self = this;
    this.matches = [];
    console.log(this.matches);

    this.baseUrl = "https://raw.githubusercontent.com/openfootball/football.json/master/2015-16/en.1.json";

    this.loadAllMatches = function(){

        $http({
            method: 'GET',
            url: self.baseUrl
        }).then(function successCallback(response){
            self.matches = response.data.rounds;
            console.log(self.matches);

        }, function errorCallback(response) {
            alert("Some error ocurred. Check Console");
            console.log(response);
        });
    }

}]);``

You can view the JSON API by clicking on this Link: EPL

Answer №1

Properly binding values when rendering data is crucial for a successful outcome. The following code snippet may provide the necessary guidance:

Controller:

var URL = 'https://raw.githubusercontent.com/openfootball/football.json/master/2015-16/en.1.json'
            $http.get(URL).then(function(response) {
                $scope.dataset= response.data;

            });

HTML:

<div ng-repeat="value in dataset.rounds">
        <div ng-repeat = "x in value.matches">{{x.team1.name}} , {{x.team2.name}}</div>
</div>  

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

Could someone kindly clarify the workings of this jQuery script for me?

I found this code online, but I'm struggling to comprehend its functionality. In order to make any edits for my needs, I need to understand how it operates. The purpose of this script is to close a panel with an upward slide animation when the "x" but ...

Code snippet for adding a div element with an embedded image using JavaScript

I am attempting to create a function that generates three div elements, each containing an image, and then appends them to the body using a for loop. As a beginner in JavaScript, I am struggling with this task. Can anyone please provide guidance on what ...

The input field automatically populates with the username that has been stored in the browser's form

Issue: I have created an input field with the type text, but upon page load, it gets automatically filled with a username saved in the browser's form data for this website's login page. I want it to show up clean when the page loads. <input t ...

Creating an interactive timer that counts down in real-time using a combination of Django and JavaScript

When passing the date and time from views.py to my HTML page, I am encountering difficulties in utilizing that information to create a countdown timer using Javascript. For example: return render(request,'page.html',{'date':i.date,&apo ...

Having trouble retrieving PHP variable values using JavaScript?

<div id="div01">01</div> <div id="div02">02</div> <img src="../img/logo.png" onclick="blueSky()"/> js function blueSky() { $.ajax({ type:'GET', url: 'test.php', success: function(respond) { document.ge ...

How to focus on an input element in Angular 2/4

Is there a way to focus on an input element using the (click) event? I'm attempting to achieve this with the following code, but it seems like there may be something missing. (I am new to Angular) sTbState: string = 'invisible'; private ele ...

What is the most effective way to update the React state based on an if-else condition within a

I am facing an issue where I have a component in my project that needs to update the parent state when clicked, but there is an if-else condition causing the state not to update in the parent component. In my project, I have two boxes with an if-else cond ...

Is there any purpose to incorporating an AngularJS directive within a comment?

Hello, I'm curious about the purpose of using an AngularJS directive as a comment. I've seen some examples where it can display an alert message, even with arguments, but I'm struggling to see the practical use of a directive as a comment. C ...

Implementing a pull-to-refresh feature in React Native using Redux

I need to implement pull to refresh functionality, but I'm unsure of what to call from _Refresh(). My actions, constants, and reducers are stored on another page. How can I trigger the API again? Thank you in advance for your assistance. class Homewo ...

"Exploring Angular UI-Router by conducting tests with the help of Mocha,

Experimenting with testing the following code in AngularJS using Mocha, Chai, and Sinon. $scope.send = function() { $state.transitionTo('module.sendhome'); }; Here is a test case for validation: it('send' , function () { scop ...

Control the button's activation status by accepting or unaccepting the two checkbox conditions

In my search through stackoverflow for help on enabling/disabling a button conditionally, I found some assistance but nothing quite matched what I needed. My situation involves two checkbox conditions rather than just one. The button should only be enable ...

Navigating through asynchronous functions without the use of promises

After delving into web-app development using angularJS with its promise library, I find myself facing a new project that lacks such a feature. How can I tackle this challenge without importing an external promise library? To simplify the situation, I need ...

Tips for obtaining the retrieved URL from an ajax call

How can I extract only the returned URL from an ajax request? I have tried implementing it like this: $.ajax({ type: "GET", dataType : "jsonp", async: false, url: $('#F ...

I had hoped to remove just one item, but now the entire database is being erased

I present it in this way <tr v-for="(foodItem, index) in filteredFoodItems"> <td>{{ foodItem.name }}</td> <td>{{ foodItem.price | currency('£') }}</td> <td>{{ foodItem.category }}< ...

Having trouble connecting with Node.js and Express; encountering ERR_CONNECTION_REFUSED

I tried following this basic tutorial: After generating the files as instructed, I ran through all the steps but encountered an issue. Regardless of the browser I used, I kept getting "Unable to connect" in Firefox and "This webpage is not available ... E ...

Custom sparkline array

In working on my sparkline chart, I have the following code snippet: <div sparkline="" values="4,4,7,5,9,6,4" data-type="line" data-height="80" data-width="100%" data-line-width="2" data-line-color="#dddddd" data-spot-color="#bbbbbb" data-fill-c ...

Working with HTML5 canvas to draw multiple images

Here is the code I'm working with: http://jsfiddle.net/zyR9K/4/ var Enemies = { x: 25, y: 25, width: 20, height: 30, speed: 0.5, color: "#000", draw: function () { canvas.fillStyle = ...

Troubleshooting problem in Java related to encoding with XMLHttpRequest

Currently, I am utilizing XMLHttpRequest for an ajax call to my server. Let's consider the call: http = new XMLHTTPRequest(); var url = "http://app:8080/search.action?value=ñ" http.open("GET",url,true); http.setRequestHeader("Content-type", "applica ...

Loop through each instance of a data record in a JSON document using Vue's v-for directive

I am currently working on a project that involves extracting data from a website that monitors traffic jams and maintenance work. My goal is to specifically retrieve information about traffic jams and display them individually. The code I am using utilize ...

Angular 2/webpack error: Unable to find require reference

I have integrated an HTML template from a graphic design company into my Angular 2 project using node and webpack. This HTML template includes various scripts like: <script src="js/jquery.icheck.min.js"></script> <script src="js/waypoints. ...