What could be causing the issue with Angular JS's "ng-repeat" not functioning properly?

Presenting my owl crousal:

<section id="intro">
                    <div class="sm-holder">
                        <div class="sm">
                            <a href="#"><i class="fab fa-facebook-f"></i></a>
                            <a href="#"><i class="fab fa-twitter"></i></a>
                            <a href="#"><i class="fab fa-instagram"></i></a>
                            <a href="#"><i class="fab fa-linkedin-in"></i></a>
                        </div>
                    </div>
                    <h1>
                        <span class="year">2020</span>
                    </h1>
                    <div class="owl-carousel owl-intro owl-loaded owl-drag">
                        <div class="owl-stage-outer">
                            <div class="owl-stage"
                                style="transform: translate3d(0px, 0px, 0px); transition: all 0.25s ease 0s; width: 21010px;">

                                <div class="owl-item cloned active">
                                    <div class="item" style="background: url(../Administration/MainPageHeader/camels1.jpg)">
                                    </div>
                                </div>
                                <div class="owl-item cloned">
                                    <div class="item" style="background: url(../Administration/MainPageHeader/camels5.jpg)">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="owl-counter"></div>
                </section>

Everything appears to be working fine.

Now,

I am looking to make it dynamic.

I want to repeat

and change camels1.jpg based on values from the database.

I have developed an Angular application.

In my scope

I have

  $http.get('http://192.168.1.40/Test/Apis/GetHeaderImages.ashx')
                .then(function (response) {
                        $scope.headerImages = response.data;
                        var arr2 = JSON.parse(JSON.stringify(response.data));
                        $scope.headerImages = arr2;
                });
here headerImages = 0: {Id: 5, ImageUrl: "camels7.jpg"} 1: {Id: 6, ImageUrl: "20202902051438KC.jpg"}

I have successfully executed the task.

Welcome to
Camel Racing Union
2020

         <div class="owl-carousel owl-intro owl-loaded owl-drag">
                    <div class="owl-stage-outer" >
                        <div class="owl-stage" 
                            style="transform: translate3d(0px, 0px, 0px); transition: all 0.25s ease 0s; width: 21010px;"id="owl-stage">
                             <div class="owl-item cloned"    ng-repeat="x in headerImages" >
                                <div class="item" style="background: url(../Administration/MainPageHeader/{{x.ImageUrl}})">

                                </div>

                            </div>
                        </div>
                    </div>
                </div>
              
                </section>
         <div class="owl-counter"></div>

Answer №1

Managed to get it functioning by utilizing asp.net tags

 <div class="owl-carousel owl-intro">
                                  <div class="item" style="background: url(../Administration/MainPageHeader/camels5.jpg)"></div>
                                <%foreach (var item in imagesUrl)
                                    {%>
                          
                                 <div class="item"  style="background: url(<%=item %>)">

                                </div>
                     <%

                                    } %>
                           </div>
                    <div class="owl-counter"></div>

Apparently, ng-repeat was not properly repeating the elements

Answer №2

It is recommended to set it as $scope.headerImages instead of just headerImages within the API callback function.

$scope.headerImages = arr2;

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

What is preventing me from loading Google Maps within my Angular 2 component?

Below is the TypeScript code for my component: import {Component, OnInit, Output, EventEmitter} from '@angular/core'; declare var google: any; @Component({ selector: 'app-root', templateUrl: './app.component.html', st ...

Monitoring the validity or errors in AngularJS input fields

I'm attempting to observe the $error or $valid status of a control. Here is the control in question: <form id="myForm" name="myForm"> <input name="myInput" ng-model="myInputMdl" business-validation/> </form> The business-validat ...

Retrieve specific components of objects using a GET request

When visitors land on my web app's homepage, a GET request is triggered to fetch a current list of Stadiums stored in the database through my API. However, the Stadium objects retrieved are packed with unnecessary data, particularly extensive arrays o ...

Utilize MetroUiCSS to effortlessly integrate a sleek calendar into your AngularJS application

I'm looking to incorporate a calendar from Metro Ui CSS into my project. Here is the link to the calendar: However, I am struggling with how to activate the calendar. I have already included all necessary scripts in my index.html (3 scripts) and have ...

Steps for changing tabs in Ionic depending on a specific condition

I have a mobile app built with the Ionic Framework that features 4 tabs, but I want to limit the visibility of only three tabs at a time. The first two tabs (Tab1 and Tab2) are always visible. However, the third tab should display either Tab 3a or Tab 3b ...

What is the process for converting an Angular UTC timestamp to a local timestamp?

Is it possible to convert a UTC timestamp to a local time timestamp using any function or method? I am sending the timestamp to angular moments, but the server's timestamp is in UTC. ...

The functionality of scope.$observe is unavailable within an AngularJS Directive

Consider the snippet below: appDirectives.directive('drFadeHighlight', ['$animate', '$timeout', function ($animate, $timeout) { return { scope: { isWatchObject: '=' }, restric ...

Dealing with a Nodejs/Express and Angular project - Handling the 404 error

Recently, I decided to dive into learning the MEAN stack and thought it would be a great idea to test my skills by building an application. My goal was simple: display a static variable ('hello') using Angular in the HTML. However, I ran into an ...

Creating a series of text messages for Push Notifications using FCM in conjunction with Ionic 1. Multiple lines of

I've been attempting to send push notifications with multiline text messages. I've experimented with various techniques such as using setBigStyle in FCMService.java, HTML.fromHTML, and others, but haven't been successful in getting the messa ...

Start with Angular routing, then switch to mvc routing if needed

My project utilizes Angular and node.js on IIS 7.5 for the frontend, and a .NET Web API for backend calls. The Angular routing and API routing are working smoothly when testing with Visual Studio/IIS Express and ng serve. However, they run on separate por ...

Exploring AngularJS and Express with Node.js: navigating routes and refreshing pages

Everything seems to be running smoothly on my app, but the moment I hit F5 in my browser is when an issue arises. The structure of my app is as follows: Using nodeJs and express, with the following routes set up in Express: core.app.get('/', f ...

Error message appears when attempting to submit a form with empty values in NodeJs

I need help troubleshooting a display error that occurs when setting empty values in form fields. When I delete the row with res.redirect('/') and then attempt to register, if I refresh the page later, an error appears. However, if I keep this re ...

AngularJS iOS keyboard not disappearing post iOS 10 update

After updating my device to iOS 10, I encountered an issue with hiding the iOS keypad when switching from one view to another. This functionality was working perfectly fine on iOS 9.3. Previously, I had programmed it to intercept certain elements and auto ...

Access a specific JSON value using AngularJS

When using AngularJS to read a specific JSON value, I encountered the following issue: $http({method: 'GET', url: urlVersion}). success(function(data, status, headers, config) { console.log("success data " + status); $scope.ext = data.ve ...

Why won't my controller function fire with ng-click in AngularJS?

I'm having trouble getting a function to execute when my button is clicked. Despite the fact that this code appears correct, the function defined in my controller isn't being triggered. The code compiles without errors as shown in the console. A ...

"Discover the step-by-step guide for incorporating password reset functionality in AngularJS using UI router

I am currently working on an AngularJS application that includes login, registration, and forgot password features implemented using JWT. Additionally, I am using UI Router for managing various states within the app. When a user clicks on the "forgot pass ...

What is the method of displaying a querystring on my Angular view page without relying on a controller?

My experience lies in utilizing AngularJS 1. This excerpt showcases the stateprovider configuration present in my config.js file: JavaScript .state('projects', { abstract: true, url: "/projects", templateUrl: "views/common/master_pa ...

What causes index.html to be returned instead of app.css?

I deploy my Angular application using an express server. var express = require('express'); var server = express(); server.use(express.static('./app')); server.all('*', function(req, res) { res.sendFile('index.html&apos ...

What could be causing AngularJS to truncate my URL in the search bar?

Currently, I am in the process of setting up a state provider for a CRUD website. One issue I encountered is that when I navigate to www.mysite.com/posts/mypost, the URL gets shortened to www.mysite.com/mypost and does not trigger the controller as intend ...

The ng-repeat function is iterating through the array multiple times

Using ng-repeat to bind the same array multiple times. JavaScript : $scope.currentitem = item; $scope.currentitemCategory = $scope.currentitem.category.split(','); console.log($scope.currentitemCategory); HTML: <div ng-repea ...