getTestimonials: function() {
Requests.postData({
action1: 'getTestimonials'
}, {
market: "sg"
},
function(res) {
$scope.Testimonial = res.res;
console.log(res.res);
},
function(rej) {
console.log('rejected');
});
},
我需要获得航空公司名称{{Testimonial}}给我:
[{" VISITORNAME":" MICHAEL"" DEPARTURE":"新加坡"" DESTINATION&#34 ;: "上海"" AIRLINE":"新加坡 航空公司"," TEXT":"非常有效率和高效率 SERVICE"},{" VISITORNAME":" AMY""离境":"新加坡""目的地: #34;:"约翰内斯堡"" AIRLINE":"卡塔尔 AIRWAYS"," TEXT":"我通过SALMA,世界卫生组织非常有帮助 有礼貌。即使我在2会议期间在会议上被占领了 DAYS,我们通过电子邮件管理。一开始,我们开始 最终确定交易与我联系 PHONE"},{" VISITORNAME":" ANTHONY"" DEPARTURE":"新加坡"" DESTINATION&#34 ;:"首尔"" AIRLINE":"新加坡 AIRLINES"," TEXT":"这是我与SKYLUX和旅行的第一次体验 很多业务。 NELLY在电子邮件上的转动是非常快速的 很有帮助。总体服务是10/10。"}]
答案 0 :(得分:2)
$scope.Testimonial
这是一个数组。航空公司名称位于$scope.Testimonial[i].airline
,其中i
是您要访问的元素的索引。
如果您的视图使用循环(ng-repeat
),则可以执行以下操作:
<span ng-repeat="t in testimonial">{{t.airline}}</span>
答案 1 :(得分:0)
使用angular.fromJson(jsonString)将Json转换为javascript对象。
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>