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

309
Vistas
How to use @apply correctly in AngularJs

I am facing some issues while trying to make something like this-

I am having a table of employees with their phone numbers I have created a button that will redirect me to another portal using the phone number of the employees.

The issue that I am facing here is - for the initial button click the phone number is getting an empty string, which is fine I have initialized it as an empty string but I am updating the $scope variable value but that is not working. I tried putting $apply() and $watch(). But that is also throwing error -

Error: [$rootScope:inprog]

How can I resolve this? My code -

  <a id="hiddenRedirectButton" href="https://my-site/employee-logs.php?auth_token=<?=echo $token;?>&phoneNumber={{number}}" target="_blank">
                
<table>
  <tr ng-repeat="employee in data">
   <td class="text-center"><button class="btn btn-primary" ng- 
    click="redirect(employee.cellPhone)">Redirect</button>
   </td>
  </tr>
</table>
//Angularjs code -
$scope.number=""; 
$scope.redirect=(number)=>{
   console.log("redirecting to other portal");
   $scope.number=number;
   $scope.$apply(); // Error: [$rootScope:inprog]
   document.getElementById("hiddenRedirectButton").click();
}

For First time button click I am not getting the phone number in the url bar, second time I am getting the number. I am doing this just because I have to open the link on new tab I can't able to find any way to do this using window.location.href.

about 4 years ago · Juan Pablo Isaza
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