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”:“迈克尔”,“起飞”:“新加坡”,“目的地”:“上海”,“航空公司”:“新加坡航空公司”,“文本”:“非常迅速和高效的服务!”},{"VISITORNAME":"AMY",“起飞”:“新加坡”,“目的地”:“约翰内斯堡”,“航空公司”:“卡塔尔航空公司”,“文本”:“我通过SALMA,世卫组织非常乐于助人和礼貌。尽管我在两天的时间里忙于会议,我们还是设法通过电子邮件迅速地进行沟通。有一次,我们开始敲定她通过电话联系我的交易“},{"VISITORNAME":"ANTHONY",”起飞“:”新加坡“,”目的地“:”汉城“,”航空公司“:”新加坡航空“,”短信“:”这是我第一次与SKYLUX公司打交道,我经常出差。耐莉在电子邮件上的转变是非常迅速和有帮助的。总的服务是10/10。“}
发布于 2016-09-08 07:51:30
$scope.Testimonial这里是一个数组。航空公司名称位于$scope.Testimonial[i].airline,其中i是要访问的元素的索引。
如果您的视图使用的是一个循环(ng-repeat),您可以这样做:
<span ng-repeat="t in testimonial">{{t.airline}}</span>发布于 2016-09-08 07:56:53
使用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>https://stackoverflow.com/questions/39385293
复制相似问题