Using a ng-repeat directive with a custom marker from ng-map causes $digest loop errors, yet the functionality remains intact

Presently, I am utilizing this library to incorporate custom markers on a map.

I successfully implemented it without any errors on Plunker, but encountered issues when trying to replicate the same on my own website (despite using identical script src links).

While ng-repeat functions as expected on my page, I am faced with two lengthy $digest loop errors.

Here is my list:

$scope.list = [{ name: 'test', pos: [41, -87] }, { name: 'test2', pos: [40, -86] }];

And this is the corresponding HTML:

<ng-map zoom-to-include-markers="auto" style="height:200px;width:400px;">
    <marker ng-repeat="item in list" position="{{item.pos}}"></marker>
</ng-map>

The above code runs without errors, however,

<ng-map zoom-to-include-markers="auto" style="height:200px;width:400px;">
    <custom-marker ng-repeat="item in list" position="{{item.pos}}">
        <div style="background-color:white;border: 1px solid black;">this is a test</div>
    </custom-marker>
</ng-map>

produces additional errors each time an item is added to the list, although it still functions properly.

The reason behind its functionality discrepancy between Plunker and my site remains unclear. My site employs ASP.NET 5 for serving, matching the versions used on Plunker. Additionally, ng-animate, ng-resource, and various other non-angular related components are utilized on my site, which should not impact this scenario. (I hope)

If necessary, here are the dependencies loaded in my controller:

function ($scope, $rootScope, restData, NgMap) {

and in the app module:

var app = angular.module('app', ['ngResource', 'ngMap'])

Answer №1

I managed to resolve the issue on my own.

Prior to posing this question, I attempted to utilize this solution, but it didn't work as anticipated. However, after further tweaking, it finally worked on my second attempt.

The key is to include

$scope.positions = angular.copy(data) 

and bind it separately to the 'positions' variable if you wish to rebind. Binding directly from the frontend to the data itself won't achieve the desired result.

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

Using AngularJS ui-router ui-sref results in the error message "Uncaught TypeError: Cannot read property '0' of undefined."

I am currently working on an angularJS component that utilizes ui-router with 2 straightforward route states. export default function Routes($stateProvider, $urlRouterProvider, $locationProvider) { $stateProvider .state('details', { ...

Exploring AngularJS $compile and the concept of scoping within JavaScript windows

I've encountered a scoping issue with the use of this inside an angular-ui bootstrap modal. The code below functions perfectly outside of a modal, but encounters problems when run within one: var GlobalVariable = GlobalVariable || {}; (fun ...

Is it advisable to combine ng-change with ng-blur in AngularJS?

Seeking clarification on the correct usage of AngularJS's ng-change and ng-blur from an expert. Specifically, when updating a form value. In the code snippet below, I have a dropdown where I would like to trigger overrideBusinessDec() when the user ...

Populate the AngularJS scope with a dynamically generated array

My Angular Application is functioning properly with <script> var app = angular.module('MyApp', []); app.controller('myCtrl', function ($scope, $sce) { $scope.urls = [ { "url": $sce.t ...

The `Click()` functionality experiences malfunction in Protractor automation scripts

I am currently automating my tests using Protractor and Appium for an AngularJS website with the Jasmine framework in an iPad simulator. Although the sendkeys() function is working fine for entering the username and password, I am facing issues when clicki ...

Retrieving Data from Outside Source using AngularJS

Is there a way to retrieve JSON-Text-Stream data from a specific URL (e.g. SOMEURL/ean.php?id=4001513007704)? The returned result typically appears as follows: { "product": { "ean_id": "4001513007704", "title": "Gerolsteiner Mineralw ...

When implementing jQuery $.ajax with Angular, the DOM fails to update

Based on the value retrieved from an XHR call to the server, I am looking to display different content: <div class="container"> <div class="header" ng-controller="MyController"> <div ng-switch on="myScopeVar"> <d ...

Is there a way for me to interpret and process this JSON data?

AngularJS is receiving JSON data from an ArrayList through a get request. The data includes information such as ID, area, gender, and highest education level. 0: Object id:1 area: "State" gender: "Both" highestEd: 36086 ...

The ng-repeat operation is invoked several times

Here's the ng-repeat code that I have written: <div class="anchor" ng-repeat="race in races" ng-class="showdata (race)"></div> $scope.showdata = function(data) { var raceId = data.raceId; if(raceId == 66666666) { con ...

Tips for sending data from Jade to a Node.js endpoint function

I am unfamiliar with Express and I am trying to figure out how to pass the user's username from a Jade file to an endpoint function in my JavaScript file. Below is the code for the endpoint function in index.js: router.get('/userdetail', fu ...

Strategies for extracting value from getCurrentUserSync in AngularJS

Can anyone help me retrieve this value from the Profile variable? I have been unsuccessful in my attempts to get it. When I check the data console.log(this.Profile), it displays the data shown in the image below: this.Profile = Auth.getCurrentUserSync(); ...

Transform form data into a specialized JSON structure

I have a form set up in the following way: <form id="myForm" ng-submit="submitForm()"> <select name="ItemName" ng-controller="ItemController"> <option value="" selected disabled>Select</option> <option ng-rep ...

Tips for Retrieving Html Element Attributes Using AngularJS

Update: Even though the discussion veered off track, the main question still stands - how can I access an attribute of an HTML element within an Angular controller? Check out my attempt on Plnkr: http://plnkr.co/edit/0VMeFAMEnc0XeQWJiLHm?p=preview // ...

Dealing with Errors When Working with Angular Promises

Currently, I am in the process of mastering promises within Angular. In my code snippet, I have two "GET" requests that I need to execute sequentially. Everything is functioning properly, but I'm unsure about how to handle errors in this scenario. If ...

No data returned from AngularJS $q.all

I desperately need assistance with the following problem. I am querying Firebase to retrieve a list of tasks sorted by priority (task date), then iterating through the results. For each task, I am fetching its related job from another branch in Firebase, a ...

The power duo of Jasmine and Angular: unleashing the potential of

My Angular application has defined constants for the application like so: var module=angular.module('abc'); module.constant('constants',{ INTERNAL_VALUE:1 }); Within my controller, I have the following code: if(someService.getInter ...

Refresh the dropdown menu selection to the default option

My HTML dropdown menu includes a default option along with dynamically generated options using ng-options. The variable dropdown is bound to the dynamic options, not the default one. <td> <select ng-model="dropdown" ng-options="item as item.n ...

Angular code isn't functioning properly

I recently started coding in Angular.js using WebStorm: <!DOCTYPE html> <html ng-app="store"> <head lang="en"> <meta charset="UTF-8> <title></title> </head> <body ng-app="store"> <script src="bowe ...

Transferring items between containers with stylish animations in AngularJS

Two of my divs have different contents, with one initially empty and the other filled with items. By clicking on an item in the first list, I want to transfer it over to the second list through a visual animation that implies movement from right to left. W ...

Looking for suggestions on how to bring this idea to life

I'm searching for a solution using JavaScript, jQuery, or Angular. I've created three random arrays like this: for example: (The values are randomly generated from the array ['member', 'medical', 'rx', 'disabi ...