Display data retrieved from the server using AngularJS

I received the following JSON data from the server: {"start":"29-11-2014","end":"31-12-2014","pris":"372.27"}

Within my .success function, I have $scope.paymentInfo = data; then I attempt to display it in my HTML view like this

{{ paymentInfo.start }}

However, it does not work. If I try {{ paymentInfo }}, it shows the entire JSON object. What do I need to do to access the start, end, etc. values?

        $scope.selectMembership = function(values){

        //console.log(values);


        centerSettings.getPriceForPeriod(values)

            .success(function(data) {
                console.log(data);
                $scope.paymentInfo = data;
            })
            .error(function(data) {
                console.log('Error fetching centers');
                console.log(data);
            });
    };

Answer №1

In order to convert the string into a Json object, you should consider deserializing it.

One method to try is using

$scope.paymentInfo = angular.fromJson(data);

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

Unable to retrieve JSON data from the given URL

Here is the JSON data I have: { "status": "ok", "count": 1, "data": { "6217895": { "clan": { "role_i18n": "Saha Komutanı", "clan_id": 16682, "role": "commander", ...

Retrieve the controller function in AngularJS and then pass it as an argument to $injector.invoke() for execution

Initially, I had set up two controllers in the following way: function ControllerA(DependencyA, DependencyB) { // code } function ControllerB(DependencyC, DependencyD) { // code $injector.invoke(ControllerA); } However, for minification purp ...

Can you provide a visual representation of the JSON structure?

$data = array('name'=>'John', 'age'=>25, 'city'=>'New York'); I am practicing my PHP skills by using cURL for making a POST request. Assuming the given array is converted into JSON format, what wo ...

What is the best method to extract a specific value from a JSON object?

I have parsed a JSON file to extract data such as "Floor", "flat_no", and "Flat_id". Here is an example of the JSON structure: { "results": [ { "Flat_id": "1", "cat": "2", "Flat_no": "101", "Floor": "1", "Flat_t ...

Retrieve the precise response parameter using urllib in Python

Is there a way to process the token information obtained from a web request using urllib in Python? from urllib import request from urllib.parse import urlencode response = request.urlopen(req, data=login_data) content = response.read() The response typic ...

Bringing JSON information into Java without the need for escape characters

I'm currently fetching Json data from a .json webpage using an HttpResponse in Java. The code snippet String Json = EntityUtils.toString(response.getEntity()) is then used to store the Json data as a String. Unfortunately, this process alters the for ...

AngularJS form: Collecting and saving radio button group choices in an array or posting selections to the server

" I'm a beginner in angularjs" 1- Situation Description: - Developing a Survey with multiple Questions and Answers, - Automatically rendering Questions and Answers from the database using angularjs, - After completing the Survey, ...

PHP REST API to handle requests and generate corresponding responses

I am currently struggling to find a solution for accurately translating the responses and requests for my PHP REST API. Here is an example of an array that I receive from the API: [{ "id": "49557a36-028b-40c6-b2d8-8095468af130", "startDate": "2020-04- ...

Error encountered while making a Jquery Ajax request to Rest service

I have created a RESTful Web Service: import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; @Path("/todo") public class TodoResource { @GET @Produces({MediaType.APPLICATION_JSON}) public To ...

What is the solution for resolving the Angular error 'Cannot read property "_co.x" of undefined'?

Currently, I am facing an issue with nested JSON objects on a form that sends data to a database. Despite trying the *ngIf statement as recommended in Angular 5 - Stop errors from undefined object before loading data, the view does not update even after th ...

Discovering particular segments in strings that include specific characters or symbols, and subsequently establishing a connection to those segments

My current data storage method involves using JSON strings in a database. However, due to the presence of quotation marks in the JSONs, the database converts all quotation marks to ", making Unity unable to deserialize the JSON properly. This res ...

Repairing the scientific notation in a JSON file to convert it to a floating

I'm currently facing a challenge with converting the output format of certain keys in a JSON file from scientific notation to float values within the JSON dictionary. For instance, I want to change this: {'message': '', &ap ...

Transforming a few lines of PHP header code to Classic ASP

I am encountering an issue with two files that I have: A locally hosted project coded in Ionic/AngularJS that is attempting to retrieve JSON data from an ASP file. An external ASP File which generates JSON data based on database values from a query. Eve ...

Can someone please provide me with the correct syntax for a jQuery AJAX PUT request that is JSON encoded?

Here is the ajax PUT request that I have written: jQuery.ajax({ url: url_lab_data+"backend/read/{\"f_anid\":"+anid+"}", type: "PUT", data: JSON.stringify({"read": 1}), ...

Is there a way to bypass strict JSON parsing when using jQuery's .ajax() function?

From jQuery 1.9 onwards, when using dataType: json in a .ajax call and the response body cannot be parsed as JSON, the request will fail silently: The parsing of JSON data is strict; any malformed JSON will be rejected with a parse error. Starting from ...

Assign a value to a variable within the $_POST array for validation purposes using Codeigniter

I am currently developing a WebSocket based application using Codeigniter. The data is being received as a JSON string (not via a POST Method) and I want to utilize Codeigniter's built-in form_validation method to validate this JSON data. Here are th ...

Having issues with the functionality of my radio button in AngularJS

As I delve into Angular and experiment with some code, I am focusing on implementing the following functionality: 1. Depending on the user's preference for adding additional details, they can choose between 'yes' or 'no' using radi ...

Working with JSON in Python depending on certain conditions

I am a beginner in Python and currently working on processing JSON data from this source. I have successfully imported the JSON data into Python and extracted specific information using the following code: from urllib.request import urlopen import json ...

Struggling to Transform XML into a Text Input within a C# SOAP Web Service Function

Recently, I was tasked with developing a C# SOAP Webservice that is capable of converting data from JSON to XML and vice versa. So far, I have successfully implemented the service along with two methods. The conversion method from JSON to XML is functionin ...

how to implement a collapsed row feature in an angular table row

My table contains collapsed rows with additional 2nd-level information, but not all rows have this data. Is there a way to create a controller that will display a 2nd level collapse row only if the corresponding JSON script includes 2nd level data? ...