我使用$http.get来获取由MailID和SubscribedDate组成的数据。结果被分配给$scope.subscriber。我将拥有一个包含所有MailID值的数组,比如:["john@msn.com","peter@gmail.com", "mike@stack.com"]
getAll();
function getAll() {
var servCall = APIService.getSubs();
servCall.then(function (d) {
$scope.subscriber = d;
}, function (error) {
console.log('Oops! Something went wrong while fetching the data.')
});
发布于 2017-08-03 21:32:50
使用javascript map
函数获取电子邮件ids
servCall.then(function(d) {
$scope.mailIDarr= d.data.map(o=>o.MailID);
}, function(error) {
console.log('Oops! Something went wrong while fetching the data.')
});
发布于 2017-08-03 21:51:58
<ArrayOftbl_Subscribers xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/WebAPIAndAngular.Models">
<tbl_Subscribers>
<MailID>first value second value third value</MailID>
<SubscribedDate>2017-08-01T16:44:06.391</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>third value fourth value sixth value</MailID>
<SubscribedDate>2017-08-01T16:48:38.977</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>kurma</MailID>
<SubscribedDate>2017-08-01T19:55:04.355</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>belekas</MailID>
<SubscribedDate>2017-08-02T05:41:32.472</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>rerere</MailID>
<SubscribedDate>2017-08-02T05:45:06.672</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>fsdfsd</MailID>
<SubscribedDate>2017-08-02T05:45:41.483</SubscribedDate>
</tbl_Subscribers>
<tbl_Subscribers>
<MailID>1111</MailID>
<SubscribedDate>2017-08-02T06:33:37.331</SubscribedDate>
</tbl_Subscribers>
</ArrayOftbl_Subscribers>
https://stackoverflow.com/questions/45485722
复制相似问题