"Using AngularJS to fetch data with $http and store it in an

Utilizing $http.get to retrieve data which includes MailID and SubscribedDate. The results are stored in $scope.subscriber. I am interested in extracting an array of all MailID values such as:

["<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5f353037311f322c31713c30">[email protected]</a>", "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4a4b1a0b1a694b3b9b5bdb8fa">[email protected]</a>", "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="89e4e0e2ecc9fafde8eae2a7eae6">[email protected]</a>"]

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.')
});

Answer №1

Implement the map function in JavaScript to extract the email addresses.

apiCall.then(function(response) {
    $scope.emailArray = response.data.map(obj => obj.Email);
}, function(err) {
    console.log('An error occurred while retrieving the data.');
});

Answer №2

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

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Creating a dynamic polyline with custom data on Mapbox is a great way to enhance your mapping experience

Hey everyone, I'm looking to create a polyline or path on Mapbox using my own data. I came across an example on mapbox.com that shows how to draw a sine wave on the map. How can I customize this example to use my own data? <!DOCTYPE html> <h ...

When attempting to access Element.object3D in A-frame using TypeScript, an error stating "The 'object3D' property does not exist on the 'Element' type" is encountered

As a Japanese student, I ask for your understanding regarding my limited English proficiency. Currently, I am working on developing an a-frame library that utilizes anime.js in TypeScript to create animations. However, I encountered an issue when attemptin ...

Jest and Enzyme failing to trigger `onload` callback for an image

I'm having trouble testing the onload function of an instance of the ImageLoader class component. The ImageLoader works fine, but my tests won't run properly. Here's an example of the class component: export default class ImageLoader extend ...

Troubleshooting a bug in React TypeScript with conditional logic

I have a new message button and a few conversations. When I click on a conversation, the right side should display the message box. Clicking on the new message button should show the create new message box. Here are my useState and handlers: const [newMess ...

AngularJS encounters an error message stating, "The data being posted is invalid in syntax according to the client."

Angular post request $http({ method: 'POST', url: '/DineOut/send', contentType:'application/json', dataType:'json&ap ...

the transparency feature in three.js is completely malfunctioning

I've been browsing through some questions that have already been asked by others here, and one that caught my attention is: Transparent background with three.js I am struggling to make the background transparent instead of black as described in the ...

Generate an image, PDF, or screenshot of a webpage with the click of a button

I've been searching for a solution that would enable users to click a button and save an image or PDF of the current page. The content on the page is dynamic and dependent on user input, resulting in sequences displayed in various colors. I'm loo ...

Ways to showcase information in real-time based on user interaction

I've created a form (php file) that enables users to input investment information into the database. They can choose investments from a dropdown list (previously entered into the database), add additional details, and submit them to the database. I&ap ...

React - Updating the document title upon user navigation away from the current page

I have encountered a challenge and I am seeking guidance on how to resolve it. Throughout our website, all pages have a default title based on our index.html file: <html lang="en"> <head> <title>My Page Title</title> ...

Zoom out the slider when scrolling

Take a look at this link and as you scroll down the page, notice how the image transitions to iPhone. Can anyone provide insight on how this effect is achieved? ...

Transitioning Dropdowns in Angular UI Bootstrap

Hello everyone, I am completely new to both Stack Overflow and AngularJS. I'm attempting to incorporate a fade-in animation into my dropdown (using UI Bootstrap's dropdown directive) without success. This issue is quite similar to the following ...

Decreasing the height of a div that wraps a slider

Currently, I am using a slider and would like to showcase its functionality. Here is the demo link: I have tried wrapping this slider in a div element, but it unexpectedly decreases the height to 125px from the original 100%. Here is the original code: ...

Cease the use of jQuery animations

My JavaScript code snippet looks like this: $.get("/<page>.php", "userid='.$userid.'&"+status, function(data){ $("#status").show("fast").html(data).delay(4000).hide("fast"); }); On a page with multiple links triggering thi ...

Sort a JSON array alphabetically in Angular.js even when there are no key/value pairs specified

I'm having trouble alphabetizing a list using a JSON array in my code. Despite my efforts, the sorting doesn't seem to be working correctly. You can view my current code by following this link to the jsfiddle http://jsfiddle.net/hxxLaxL3/ Here i ...

In Typescript, how can we reverse the order of an enum

I am encountering a particular challenge with the following code snippet: enum MyEnum { Colors = 'AreColors', Cars = 'AreCars', } const menuTitle = ((obj: MyEnum) => { const newObj = {}; Object.keys(obj). ...

Click on a button to send the React Router path as a parameter in

I've got a React form with a submission button like this: <Link className="btn btn-secondary btn-width-200 search-submit" to={{pathname: '/booking/search', query: this.state.filters}}> Search </Link> Within the ...

Tips for submitting a form textarea input from CKEditor using AJAX

I am currently utilizing CKEditor, jQuery, and the jQuery form plugin. My objective is to submit the content of the CKEditor form through an Ajax query. Below is the code I have implemented: <form id="article-form" name="article-form" method="post" act ...

Exploring NextJS with Typescript

Struggling to incorporate Typescript with NextJS has been a challenge, especially when it comes to destructured parameters in getInitialProps and defining the type of page functions. Take for example my _app.tsx: import { ThemeProvider } from 'styled ...

Developing a react native library (create-react-native-library) incorporating a distinct react-native version within its designated Example directory

I'm looking to develop a React Native library, but the testing folder (example folder) it contains the latest version of React Native. However, I specifically need version 0.72.6 in the example folder. Is there a command for this? Current command: np ...

MEAN.JS: The need for speed - improving charging time

Scenario Currently, I am utilizing the MEAN.JS framework which consists of MongoDB, ExpressJS, AngularJS, and NodeJS. I have successfully bundled and minified all the AngularJS .js files (Controllers, Factories, Services, Directives...) using the command ...