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

198
Views
El enlace AngularJS no funciona. al llamar a una función angularjs desde la función javascript

Estoy llamando a una función angularjs desde una función javascript. desde la función javascript, estoy pasando una variable y asignando la variable a $scope.usersName. Pero el valor no cambia.

A continuación se muestra el código que he escrito.

 <!DOCTYPE html> <html data-ng-app="javaScript"> <head> <meta charset="ISO-8859-1"> <title>Call AngularJS function using JavaScript</title> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script> <script type="text/javascript"> var serviceModule = angular.module('javaScript', []); serviceModule.controller('javaScriptController', function($scope) { $scope.javaScriptCallAngular = function(value) { $scope.usersName = value; }; }); function javaScriptCall(value){ var scope = angular.element(document.getElementById('idForJS')).scope(); scope.javaScriptCallAngular(value); } </script> </head> <body id="idForJS" data-ng-controller="javaScriptController"> <h2>Click below to get User Name:</h2> <div> <button onclick="javaScriptCall('Java Honk')">Get User name from JavaScript call to AngularJS</button> <div>User Name: {{usersName}}</div> </div> </body> </html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

puede ser que pueda usar, $scope.$apply() - funcionará.

 $scope.javaScriptCallAngular = function(value) { $scope.usersName = value; $scope.$apply(); };
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!