Angular sending information from one page and retrieving it on another

The reportForm page allows users to input information and submit it to create a report.

reportData = {
 headline: $scope.headline,
 fromDate: $scope.fldFromDate,
 toDate: $scope.fldToDate,
 whatever: $scope.whatever 
}

$http.post(reportUrl + $scope.reportName, reportData)
 .then(function successCallback(data) {
    console.log("Ok");
 }, function errorCallback(err) {
    console.log("Call Report ERROR: " + err);
 });
}

I also have several generate report pages that utilize the user-submitted data to create printable reports (hence why I keep them separate).

QUESTION: How can the generate report page access the data submitted through the reportForm page?

I've looked into factories, services, and rootScope, but I'm unsure how they could facilitate this communication. Since I'm sending data to another page, how can I share this data between them using Angular functions? (I'm still new to Angular, so please go easy on me!)

In Node.js, I would typically use a router to handle read/write operations for data transfer.

Answer №1

I'm a bit unsure of what exactly you're attempting to accomplish. However, if your goal involves transferring data from one angular location to another, you can make use of a service as demonstrated by Sajeetharan in this example: Unable to bind $scope value to view on Url change

Alternatively, if you're looking to send data to a server and then retrieve it from that server, you would post the data as you've done and fetch it on another page using $http.get

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

Unable to modify div style using a JS function

I am attempting to show different divs based on the button clicked, with all starting with a display style of "none" except for one default div called "atualizacoes". After clicking a button, all divs should be set to display="none", and then the specific ...

A Guide to Retrieving HTML Content Using jQuery's Ajax Method

I am working on a page that contains Option elements with Values linking to external pages. My goal is to utilize Ajax to retrieve the selected Option's Value and use it to load content from those external pages. For example, if a user selects Volleyb ...

Exploring the functionality of Array.prototype.includes() in Angular 7 with PhantomJS testing

While testing components in my Angular application, I noticed that unit tests utilizing Array.prototype.includes() are successful in Chrome but fail when executed with PhantomJS. I found some suggestions in the responses to this question related to a simi ...

What is the process for setting up a server with Node.js?

After diving into my nodejs studies, I hit a roadblock at the point where I was supposed to create a server. Here's the code snippet for this particular script: var http = require('http'); // Import Node.js core module var server = http.cre ...

The requested style from ' was denied due to its MIME type ('text/html') not being compatible with supported stylesheet MIME types, and strict MIME checking is enforced

It's strange because my style.css file in the public folder works on one page but gives me an error on another. I'm not sure why it would work on one page and not on the other. The CSS is imported in index.html so it should work on all pages of t ...

Utilizing the same WebDriverJS instance repeatedly

As a beginner in Selenium, I successfully launched a website using the following Node.js code snippet: var webdriver = require('selenium-webdriver'); var driver = new webdriver.Builder() .forBrowser('chrome') .build(); console ...

When utilizing JavaScript to input text, I have observed that if I enter text in one text box, any previously entered value is automatically deleted

Currently, I am facing an issue with 3 text boxes in a row that I am populating using JavaScript. The problem arises when I enter text into one field and then move to the second box to input text - the value from the first text box gets removed. Below is ...

Utilize inline scripts within the views of Yii2 for enhanced functionality

I stumbled upon a jQuery code online that allows for the integration of Google Maps, and I'm looking to implement it in my application to ensure accurate address retrieval. You can find the jQuery code here. Currently, I am working with yii2 Advanced ...

What are the reasons behind the asynchronous behavior of Angular translate in version +2?

I have been using angular translate version 1.x for a while now and I find the $translate service quite easy to use. When working with this version, you can simply do the following in a controller: $scope.whatever = $translate('WHATEVER'); How ...

I need to prevent form submission when the submit button is clicked. How can I achieve this?

I'm currently developing a web application using ASP.net. Within the form, there is a submit button that has the following code: <input type='submit' value='submit request' onclick='btnClick();'>. The desired func ...

Notification for radio button selected

Looking to trigger an alert message when a radio button is not selected? Check out the code below: <form method=post name="spendform" id="spendform"> <input name="price" type="radio" class="invest-coin-check" id="pricemethod" > <button typ ...

Could an element's loading be postponed on the initial page a user lands on?

One of my clients has requested a live chat system to be added to their website. I am fully capable of implementing it, and it is included through a script tag. Additionally, they have asked for a slight delay before the chat system loads in. My initial t ...

Directive not found - unable to locate controller

The directive 'appContent' requires the controller 'appLeft', but it cannot be located. //app-nav(left) app.directive('appLeft', function () { return { restrict: 'E', replace: ...

The variable (form.onsubmit) remains unset even after assigning a value

function setFormOnSubmit(formName){ if(!formName) return; var form = document[formName]; form.onsubmit = function(){ console.log('This is the onsubmit function'); }; console.log('onsubmit successfully set ...

Initiate the python script on the client's end

Currently, I am in the process of initiating a Python script designed to parse a CSV file that has been uploaded by the user through the UI. On the client side, how can I effectively trigger the Python script (I have explored using AJAX HTTP requests)? Add ...

Unraveling the Json Object with php and angularJs

When transmitting data from AngularJS as JSON, it arrives in the following format: {data: "stdClass Object↵(↵[0] => B↵[vin] => vin123…[value] => Gambia↵[country_name] => Gambia↵)↵", status: 200, headers: function, config: Object} ...

Ways to address observables in Angular in a manner similar to deferred objects

Transitioning from AngularJS to Angular has posed a challenge for me, especially when it comes to moving from promises to observables. Below is an example of my code in AngularJS: var deferred = $q.defer(), frame = document.createElement('newFrame ...

Docker: CORS policy is blocking access to XMLHttpRequest

After creating an ASP.NET Web Application (.NET Framework) project in Visual Studio 2022 and adding a web service to it, everything seemed to work fine when testing the web service call on Local IIS. However, things took a different turn when I tried runni ...

The AJAX call returned undefined, leading to an error when trying to access the length property

I've scoured various resources to find a solution for this issue, but unfortunately, I haven't had any luck with implementing the code. The problem lies with my JSON parser function, which is designed to construct a table based on data received ...

Trim the final digits from the arrays

I have an array that contains various strings: var arr = ['1234','23C','456','356778', '56'] My goal is to filter out array elements that are less than 3 characters or more than 4 characters. The resultin ...