Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
How to pass variables from one page to another with AngularJS?

I'm working with 2 different controllers (and js files) for my index.html (controllerIndex on index.js) and pageA.html (controllerPageA on pageA.js).

index.html has 2 links that lead to the same page, but need to pass a parameter with different values depending on which one I click in order to use them for an API on controller2.

How can I do this?

index.html:

<!-- Should pass ParameterA here -->
<a ng-model="parameter" ng-init="parameter = 'parameterA'" href="pageA.html">Page A1</a> 
<!-- Should pass ParameterB here -->
<a ng-model="parameter" ng-init="parameter = 'parameterB'" href="pageA.html">Page A2</a>

pageA.js:

$http({
  method: 'GET',
  url: 'localhost:8888/ProjectName/API/items/list?type=' + parameter //where parameter = 'parameterA' or 'parameterB' depending on which link was clicked
}).then(function successCallback(response) {
   $scope.items = response.data;
  }, function errorCallback(response) {
    alert("Error");
  }); 
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I'm not familiar with Angular. But it looks to me that you can transfer your parameters simply via GET-parameters:

<a ng-model="parameter" ng-init="parameter = 'parameterA'" href="pageA.html?parameter=parameterA">Page A1</a> 

and retreive them like this on the pageA.html:

   var query = window.location.search.substring(1);
   var parts = query.split("=");
   var parameter = parts[1];
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!