2
            getTestimonials: function() {
                Requests.postData({
                        action1: 'getTestimonials'
                    }, {
                        market: "sg"
                    },
                    function(res) {
                      $scope.Testimonial = res.res;
                      console.log(res.res);
                    },
                    function(rej) {
                        console.log('rejected');
                    });
            },

enter image description here

I need to get airline name {{Testimonial}} give me :

[{"VISITORNAME":"MICHAEL","DEPARTURE":"SINGAPORE","DESTINATION":"SHANGHAI","AIRLINE":"SINGAPORE AIRLINES","TEXT":"VERY PROMPT AND EFFICIENT SERVICE!"},{"VISITORNAME":"AMY","DEPARTURE":"SINGAPORE","DESTINATION":"JOHANNESBURG","AIRLINE":"QATAR AIRWAYS","TEXT":"I LIASED THROUGH SALMA, WHO WAS EXTREMELY HELPFUL AND COURTEOUS. EVEN THOUGH I WAS OCCUPIED IN MEETINGS OVER HTE COURSE OF 2 DAYS, WE MANAGED TO COMMUNICATE PROMPTLY OVER EMAIL. ONCE, WE BEGAN TO FINALISE THE TRANSACTION SHE CONTACTED ME OVER THE PHONE"},{"VISITORNAME":"ANTHONY","DEPARTURE":"SINGAPORE","DESTINATION":"SEOUL","AIRLINE":"SINGAPORE AIRLINES","TEXT":"THIS IS MY FIRST EXPERIENCE WITH SKYLUX AND I TRAVEL A LOT FOR BUSINESS. NELLY'S TURNAROUND ON EMAILS IS VERY QUICK AND HELPFUL. OVERALL SERVICE IS 10/10."}]

1
  • You need to use ng-repeat and capture only the airline name from UI. Commented Sep 8, 2016 at 7:51

2 Answers 2

2

$scope.Testimonial here is an array. Airline names are at $scope.Testimonial[i].airline where i is the index of the element you want to access.

If your view is using a loop (ng-repeat), you can do something like this:

<span ng-repeat="t in testimonial">{{t.airline}}</span>
Sign up to request clarification or add additional context in comments.

Comments

0

convert Json to a javascript object using angular.fromJson(jsonString).

var obj = angular.fromJson(jsonString);
// obj has an array of objects, so iterate the array to get the airline name and store it in any other array or use ng-repeat to show it in the html template

$scope.airlineDetails = angular.fromJson(jsonString);

//now in the html template,
<ul>
<li ng-repeat = "a in airlineDetails">a.airline</li>
</ul>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.