When working with AngularJS, using ng-repeat to loop through elements may encounter difficulties if the key contains a colon ":"

I am facing an issue while trying to loop through a simple JSON in AngularJS using ng-repeat. The specific JSON I am working with is as follows:

$scope.lines = { 
        data: [
                { "properties": {
                    "name": "My test",
                    "test:testOne": "This is test one" }
                }
        ]
    };

The main problem lies with this property: test:testOne. Parsing this property is proving to be challenging due to the presence of a colon. I have created a jsfiddle here: http://jsfiddle.net/7MhLd/1250/ where I have attempted various methods, unfortunately, without success

Answer №1

Utilizing [] for bracket notation is a common practice in JavaScript programming. Here's an example:

<div ng-controller="MyCtrl">
    <div ng-repeat="line in lines.data">
       {{ line.properties['test:testOne'] }}
       {{ line.properties.name }}
    </div>
</div>

View Example

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

Is there a way to prevent tags from wrapping and showcase them all in a single line when utilizing the jQuery select2 plugin?

I have a requirement to prevent tags from wrapping and instead display them in a single line using the jQuery TagIt plugin. Check out my preview: https://i.stack.imgur.com/lYhsi.png My goal is to have all the tags displayed on a single line without wra ...

Creating a personalized audio player using HTML

I have created a design for an audio player that I would like to implement using the HTML audio player element. https://i.sstatic.net/vJpGg.jpg When I tried <audio></audio>, it just displayed the default player: https://i.sstatic.net/nyNj8.j ...

Tips on choosing filters and leveraging the chosen value for searching in a Vue application

I am currently working on a Vue JS application that allows users to apply filters and search a database. The user can select or type in filters, such as "to" and "from", which are then used in a fetch URL to retrieve data from a json-server. Once the user ...

How can Javascript or Jquery determine the specific event assigned to an object?

Is it possible to retrieve the properties of HTML elements using their name or id? For example: document.getElementById('id').value; //Accessing element property in JavaScript $('#id').attr('class'); // Accessing correspond ...

CSS Only Sidebar Dropdown (without using Bootstrap)

I want to create a sidebar with collapsible dropdown options and smooth animations using only pure css/js/html/jquery, without relying on bootstrap like I did in the past. Here is an example of what I created previously with bootstrap: Now, as a challenge ...

What is the best way to merge two tables together using the server-side JQuery Datatable plugin?

I recently came across an amazing example of a server-side ColdFusion jQuery datatable on this website: Check it out here However, I am facing an issue with adding a second table in the lookup. Specifically, while the primary table lists location_id, I al ...

Rotating a loaded file using THREE.js

After experimenting with the ThreeJS library for a few weeks and drawing inspiration from others, I managed to create a canvas that displays an external .stl-file. However, my main issue is that I am struggling to apply any transformations to it. While I ...

Top method for enhancing outside libraries in AngularJs

Currently, I am utilizing the angular bootstrap ui third party library as a dependency in my angular application. One question that is on my mind is what would be the most effective method to enhance the functionality of directives and controllers within t ...

Shortening Strings When Parsing Json and Storing in ADO

I am currently developing a console application that interacts with a REST API by deserializing JSON data into a C# model and then storing that model in a database table using ADO. One of the initial challenges we encountered was related to a JSON propert ...

Easy Ways to Retrieve the Current Date and Time

Is there a way to retrieve the current date and time using angularjs I attempted the following method: <b>{{Date.Now}}</b> Unfortunately, this approach did not yield the desired results. Any tips or suggestions would be highly valued. ...

Getting data from a document containing key value pairs

I have a collection of text files that are structured in a key-value pair format. "Site Code": "LEYB" "Also known as": "" "Location": "Pier Site, Poblacion del Sur, Villaba, Southern Leyte" "Contact person(s)": "" "Coordinates[1]": "11 ...

Access Denied while attempting to use Firebase

Exploring the integration of Firebase with my ionic application for the first time has presented a challenge. Despite configuring the project and linking the necessary javascript files, I encounter the frustrating 'Error: Permission Denied' when ...

Configuring Webpack for a React application with Express and Babel

I am in the process of developing a React application, utilizing React version ^15.6.1 along with Webpack, Express, Babel, and Yarn as the package manager. After successfully running the application, I am now preparing to transition it to production by co ...

"Sending the selected pass selector as a parameter to the dispatched action is causing a typing

When a selector changes its value, I want to trigger an action. To achieve this, I passed the selector with a subscription instead of passing an observable. selectedSchedulingsOnPopup$ = this.store.pipe(select(selectSchedulingsByBranch)); this.store.disp ...

An unforeseen issue arose while trying to update the data in a Chart.js chart within a Vue application

I am currently utilizing Chart.js version 3.5 along with Vue 3. After successfully creating a chart, I attempted to trigger a data change within a Vue method. However, I encountered an issue that displayed the following error message: "Uncaught TypeError: ...

Access your Vue.js application using Google Sign-In (GIS)

Having trouble with the discontinuation of gapi.oauth2 by Google and finding the new Sign in With Google tools confusing. Project Structure Looking to implement user sign-in with Google on my Vue frontend and authenticate them using OIDC server flow on ...

Transformation of characters with diacritics in DataWeave output

My JSON response contains special characters including German umlauts (ä,ö,ü). Despite setting the encoding to UTF-8, the output from dataweave shows as ü and ä and ö, and it is identified as com.mulesoft.weave.reader.ByteArraySeekableStream d ...

Incorporating dynamic images from local sources into a listview in a React Native

I'm currently having an issue with loading local images in a React Native app that I'm developing. As per the instructions provided in the documentation at https://facebook.github.io/react-native/docs/images.html It's mentioned in the guid ...

Choosing a class using Jquery through a For loop in Javascript

I have a group of images with a class applied to them. I am attempting to create a for loop that will iterate through the elements of this class. In Python, you can use "for element in thing" and I was curious if there is something similar in JavaScript. A ...

AngularJS Automatic Color Conversion from HSL to RGB

I am faced with a challenge of merging several working pieces together. Currently, I have a list of elements sorted based on their health status (ranging from 0 to 100). My goal is to color the background of each element according to its health status. Fo ...