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

310
Views
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
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!