reflija reflija - 3 months ago 6
JSON Question

angularJS json getting resource?

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."}]

Answer

$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>