Eliminate the keyword in the $http.get request for the JSON data

As a newcomer to Angular and JSON calls, I must admit that I am still learning the ropes.

My current task involves making a $http.get call to retrieve data from a JSON object. Here is an example of what the JSON object looks like:

[{
    path: "site:images/gallery/1238.jpg",
    data: {
        caption: "",
        url: ""
    }
}, {
    path: "site:images/gallery/abelone.jpg",
    data: {
        caption: "",
        url: ""
    }
}, {
    path: "site:images/gallery/carrot.jpg",
    data: {
        caption: "",
        url: ""
    }
}, 
//more objects follow
]

This is how I am calling the data:

$http.get('/_admin/index.php/rest/api/galleries/get/Restaurant?token=xxx')
.then(function(response) {
    $scope.gallery = response.data;
});

To display the retrieved data using ng-repeat:

<article ng-repeat="item in gallery">
    <p>{{item.path}}</p>
</article>

One challenge I'm facing now is figuring out how to remove the 'site:' keyword from each 'path' record.

Answer №1

When using response.data.path, it brings back a string prefixed with "site:", and has no connection to $http call; hence, it is just a basic string manipulation. Here is a simple example:

<article ng-repeat="item in gallery">
    <p>{{ item.path.slice(5) }}</p>
</article>

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

Guide on building a Dynamic factory in AngularJS

For my project, I need to implement a dynamic factory in AngularJS with a unique name. Here is an example of what I am trying to achieve: function createDynamicFactory(modId) { return myModule.factory(modId + '-existingService', function ...

Selection highlighting in a drop-down menu

My dropdown list includes the following items: <asp:DropDownList ID="ddlsendmail" runat="server" Width="250px" AutoPostBack="true" OnSelectedIndexChanged="ddlsendmail_SelectedIndexChanged" onchange="test();"> <asp:ListItem>--select--&l ...

Loading content using Ajax with the Behance API

Currently, I am facing a challenge with getting this code to function properly. The goal is to load project content onto the page when an image is selected. While I have successfully loaded images from the Behance API, I am encountering difficulties with ...

Issue with CoffeeScript and three.js: scene not defined

I've been troubleshooting this issue for hours, but I can't seem to figure out the error... Here's the error message I'm getting: Cannot read property 'add' of undefined Below is my coffeescript code file (hopefully it&apos ...

Creating JSON data from a MySQL database with PHP is a straightforward process

{ "idbarang": "ID-75192864", "namabarang": "Fruit Tea", "jenisbarang": "Minuman", "hargabarang": "6000" } attempting something like this <?php include 'databa ...

Nightwatch encounters difficulty in accessing the iframe element

While utilizing the xquery selector, I attempted to input a value into the iframe's input field, but unfortunately, my efforts were fruitless. `.frame('someid') .setValue('//input[contains(@name,"project name")]', 'Nig ...

Combining multiple dictionaries into one single dictionary array using JavaScript

In my JavaScript code, I am working with an array that looks like this: arr = [{"class":"a"},{"sub_class":"b"},{"category":"c"},{"sub_category":"d"}] My goal is to transform t ...

What is the best method for utilizing a single L.Shapefile/zip file Object and modifying the onEachFeature function for each layer?

I am currently facing an issue where I have multiple tileLayers each containing a shape file. These tile layers represent different datasets based on variables and adjust colors accordingly. I have been able to achieve this by creating three separate Obje ...

Sharing State with a Secure Route in Vue Router (using the script setup method)

Hello everyone, I'm encountering an issue while trying to send a state to the protected routes in vue-router. The error that I faced mentioned "Discarded invalid param(s) "_id", "dish_name", "description", "img" ...

The error message "TypeError: Unable to access properties of an undefined value (reading 'status') while using axios" appeared

I followed the tutorial on freecodecamp (https://www.freecodecamp.org/news/how-to-build-react-based-code-editor/) to implement a code editor in React, but I encountered an error when trying to run it in my Next.js project. The specific error message is: Ty ...

The data points on the Google Maps heatmap are not visible

We are working on developing a server side application that will utilize the Google Maps API to create weighted heat maps for visualizing data. Check out the Google Maps API documentation for Heat Maps here Despite successfully displaying the map, my Jav ...

Executing a Function Following the Completion of getAuth() in React Firebase

I have a function that needs the user id to run properly. However, the function is executing before the getAuth process is completed. const user = getAuth() getDoc(doc(db, 'users', user.currentUser.uid)) When I try to run the above code, it thro ...

The functionality of save() is not compatible with mongoose.Schema

const Information = require('./Models/Information'); ... let sampleData = new Information( dataSample ); sampleData.save( function ( error ){ console.log('testing); if ( error ) { console.log('Error occurred while saving Informa ...

What is the best way to add a button click event listener that persists through DOM changes, such as in a single-page application?

I have developed a ViolentMonkey userscript that adds an event listener to a button with the ID #mark-watched. When this button is clicked, it automatically triggers a click on the button with the ID #next-video. This functionality is necessary because the ...

Discrepancy in Metalness Between GLTF Scene and THREE.JS Editor's Environment Available at https://threejs.org/editor/

I have encountered an issue with a gltf file. When I import it into the Three.js editor (), everything appears as expected when adding an environment map. However, when I import the same gltf file into my project scene, I notice a discrepancy in the resul ...

Repeating Elements with Angular and Utilizing a Touch Keyboard

Currently, I am developing a table with various fields and the ability to add new rows. The goal is to display all the inputted data at the end. This application is specifically designed for touch screen monitors, so I have created a custom keyboard for in ...

Is there a way to convert a number into a std::string using nlohmann::json parsing?

#include <iostream> #include <string> #include <limits> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { std::cout.precision(std::numeric_limits<double>::max_digits10); // create a JSON value w ...

What is the process for implementing a decorator pattern using typescript?

I'm on a quest to dynamically create instances of various classes without the need to explicitly define each one. My ultimate goal is to implement the decorator pattern, but I've hit a roadblock in TypeScript due to compilation limitations. Desp ...

What is the best way to save JavaScript functions in documents using mongoose?

I have a need to store data along with functions in a mongodb document. {name:"data1", event:function(){ /* some code */ }} {name:"data2", event:function(){ /* some other code */ }} I am utilizing mongoose.js ORM for my current project. How should I stru ...

Type property is necessary for all actions to be identified

My issue seems to be related to the error message "Actions must have a type property". It appears that the problem lies with my RegisterSuccess action, but after searching on SO, I discovered that it could be due to how I am invoking it. I've tried so ...