错误:使用警报时,$消化已经在angularjs进展

编程入门 行业动态 更新时间:2024-10-26 19:26:12
本文介绍了错误:使用警报时,$消化已经在angularjs进展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我刚刚从控制器服务JSON数据。

和我使用一个回调函数,当它得到加载到打印成功消息。它工作正常,但它也扔,我在问题中提到的错误

// JSON文件{PC:名}//角服务VAR的服务= angular.module('服务',['ngResource'])。工厂('小工具',函数($资源){    返回$资源('/ JSON / home.json',{},{        查询:{方法:GET,则params:{},IsArray的:假}    });});//控制器功能editWidget($范围,窗口小部件){ $ scope.data = Widgets.query(功能(数据){    警报(成功加载数据--->中+ JSON.stringify(data.pc)); });}

解决方案

警报,以及确认和提示将暂停code(块的线程)的执行,在此期间,超时和时间间隔全力以赴失控,如果他们应该已经在暂停期间触发。在 $消化循环是由两个小圈,哪个过程 $ evalAsync 队列和 $手表列表。在 $ evalAsync 队列用于调度这就需要当前栈帧以外发生的工作,但浏览器的看法之前渲染。这通常是做的setTimeout(0)。在此期间,你的警觉导致该问题。

I am just getting the json data from the services in the controller.

And I am using a callback function to print the success message when it got loaded. It is working fine but it is also throwing an error which I mentioned in the question

//JSON file { "pc":"name" } // angular services var service = angular.module('Services', ['ngResource']). factory('Widgets', function($resource){ return $resource('/json/home.json', {}, { query: {method:'GET', params:{}, isArray:false} }); }); //controller function editWidget($scope, Widgets) { $scope.data = Widgets.query(function(data) { alert("Success Data Loaded ---> " + JSON.stringify(data.pc)); }); }

解决方案

alert, as well as confirm and prompt will pause the execution of code (blocks the thread), during which timeouts and intervals go all haywire if they should have been triggered during the pause. The $digest loop is made up of two smaller loops, which process $evalAsync queue and the $watch list. The $evalAsync queue is used to schedule work which needs to occur outside of current stack frame, but before the browser's view render. This is usually done with setTimeout(0). Your alert during this time causes the problem.

更多推荐

错误:使用警报时,$消化已经在angularjs进展

本文发布于:2023-11-27 20:53:03,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639562.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   进展   错误   angularjs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!