Getting AngularJS Error: "[$rootScope:inprog] $digest already in progress" without a manual $apply -
In other posts, this always involves trying to apply $ $ without the use of a secure application, But this is not the case in my example. My job is successfully returning the requested data to the API, but I can not clear this bug and it's driving me crazy. Every time .success is called in my $ http function, "error: [$ Rootscope: inprog] $ digest is already in progress" Below is my controller and service in the console. Thanks!
Services.service ('CoolService', ['$ q', '$ RootScope', '$ http', 'AUTH', function ($ q, $ rootScope, $ http, Auth ) {Var service = {create: function (payload) {var deferred = $ q.defer (); $ http success (work, data, status, header, config) {deferred ({'url': '/ api / endpoint / ',' DataType ':' json ',' method ':' post ', data: payload}) .reolve (data);}) .reer (function (data, position, header, config) {deferred.reject ("Error in request.");}); The return came back; Launch;}} return service;}]);
And here's my controller that calls the service:
controller ('CoolCtrl', ['$ scope', '$ modal ',' $ Log ',' coolservice ', function ($ scope, $ model, $ log, cool service) {getCoolData = function (input_data) {create cool service. (Input_data). Then (function (result) {new_cool = Results.results;}, function (error) {console.log ("There was an error getting new cool data");});}; var payload = {user_id: data1, cool_id: data2,} var new_cool_data = getCoolData (Payload); console log (new_col_data);}]);
The log below var new_cool_data is called before the async operation, but new_cool is assigned in getCoolData within the .then statement. Any help to get rid of this bug or not being dirty normally would be greatly appreciated!
Here is the full error:
Add this small method and apply it Call instead ()
function CheckScopeBeforeApply () {if (! $ Scope. $$ step) {$ scope. $ Applied (); }};
Comments
Post a Comment