2017-08-03 76 views
1

我使用$ http.get來獲取由MailID和SubscribedDate組成的數據。 結果被分配給$ scope.subscriber。我會活着都MailID值像數組:["[email protected]","[email protected]", "[email protected]"]

\t getAll(); 
 
\t function getAll() { 
 
\t \t var servCall = APIService.getSubs(); 
 
\t \t servCall.then(function (d) { 
 
\t \t \t $scope.subscriber = d; 
 
\t \t }, function (error) { 
 
\t \t \t console.log('Oops! Something went wrong while fetching the data.') 
 
\t \t });

+0

有什麼問題?哪些數據在'd.data'中返回? –

+0

這是JSON與MailID和SubscribedDate – neela

+0

什麼是JSON的結構?在您的問題中添加示例回覆。 –

回答

0

利用javascript map函數來獲取電子郵件ID

servCall.then(function(d) { 
    $scope.mailIDarr= d.data.map(o=>o.MailID); 
}, function(error) { 
    console.log('Oops! Something went wrong while fetching the data.') 
}); 
0

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