Here is the javascript code snippet I am working with:
$scope.fav_details = function(id1,id2,bio) {
document.getElementById(id2).style.display="none";
document.getElementById(id1).style.display="block";
$scope.getLegislatorDetails(bio);
document.getElementById(bio).click();
}
The issue arises from the click event mentioned above. It seems strange to me as I have not used $apply in my code, yet I am encountering this error. Any assistance in resolving this problem would be greatly appreciated. The getLegislatorDetails function in the code includes an API call and saves the data in a scope variable.
The error specific to AngularJS that I am encountering is as follows:
angular.js:13642 Error: [$rootScope:inprog] http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24apply
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:6:412
at n (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:137:381)
at m.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:145:312)
at HTMLButtonElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:274:247)
at HTMLButtonElement.dispatch (http://localhost/congress/js/jquery-3.1.1.min.js:3:10315)
at HTMLButtonElement.q.handle (http://localhost/congress/js/jquery-3.1.1.min.js:3:8342)
at m.$scope.fav_details (http://localhost/congress/scripts.js:938:38)
at fn (eval at compile (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:231:126), <anonymous>:4:436)
at b (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:126:19)(anonymous function) @ angular.js:13642
angular.js:13642 Error: [$rootScope:inprog] http://errors.angularjs.org/1.5.6/$rootScope/inprog?p0=%24apply
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:6:412
at n (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:137:381)
at m.$digest (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:142:30)
at m.$apply (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:145:401)
at HTMLButtonElement.<anonymous> (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:274:247)
at HTMLButtonElement.dispatch (http://localhost/congress/js/jquery-3.1.1.min.js:3:10315)
at HTMLButtonElement.q.handle (http://localhost/congress/js/jquery-3.1.1.min.js:3:8342)
at m.$scope.fav_details (http://localhost/congress/scripts.js:938:38)
at fn (eval at compile (https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js:231:126), <anonymous>:4:436)(anonymous function) @ angular.js:13642
To access the getLegislatorDetails function, you can refer to the following link:
https://github.com/anirbanmishra/congress.php/blob/master/getLegislatorDetails