2017-08-03 18 views
1

私はMailIDとSubscribedDateで構成されるデータを取得するために$ http.getを使用しています。 結果は$ 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

MailIDとSubscribedDateを持つjsonです。 – neela

+0

JSONの構造は何ですか?あなたの質問にサンプルの回答を追加してください。 –

答えて

0

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>

取得するjavascriptの使用
関連する問題