Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

129
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda