[英]AngularJS $http.get results to array
我正在使用$ 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.') });
使用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.')
});
<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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.