Javascript 在ng repeat中加载指令时firefox中的停止脚本警告

Javascript 在ng repeat中加载指令时firefox中的停止脚本警告,javascript,angularjs,angularjs-ng-repeat,user-experience,Javascript,Angularjs,Angularjs Ng Repeat,User Experience,我的应用程序中有“全选”功能。我在循环中至少有100个项目可供选择。我得到每一项,并将其添加到单独的$rootScope变量中,该变量用于ng repeat on li元素。在这个元素中,我还添加了“mydirective”来执行一些渲染。这将在Firefox上生成停止脚本问题 在指令呈现中,通过$timeout执行。但问题仍然存在。请在这方面帮助我。以下是我的指示 app.directive('addToCartDirective', function ($timeout, $rootScop

我的应用程序中有“全选”功能。我在循环中至少有100个项目可供选择。我得到每一项,并将其添加到单独的$rootScope变量中,该变量用于ng repeat on li元素。在这个元素中,我还添加了“mydirective”来执行一些渲染。这将在Firefox上生成停止脚本问题

在指令呈现中,通过$timeout执行。但问题仍然存在。请在这方面帮助我。以下是我的指示

app.directive('addToCartDirective', function ($timeout, $rootScope) {
return function (scope, element, attrs) {
    $timeout(function () {
        var params = scope.$eval(attrs.addToCartDirective);
       global.leftBarAddClassicIdeal(params['size'], params['product'], params['id'],$rootScope,params['index']);           
    },100);
};
}))

HTML

<ul class="left-menu1"  id="ul_left_bar_ideal_0"  >
  <li add-to-cart-directive="{size:'{{key}}',index:'{{$index}}',product:'Ideal',id:'li_left_bar_ideal_{{$index}}'}" style="width: 100px; height: 120px;min-height:120px" class='left-bar' data-ng-repeat="idealImage in currentCart" id='li_left_bar_ideal_{{$index}}'  ng-if="idealImage.imgSize == key">
   <div class='img_container'>
       <a  data-ng-click="_appService.displayDetailView(idealImage.imgName,null,'Ideal',key);" data-current-size="{{key}}" href ><img data-custom-width='' data-custom-height=''  class='pic' style='display:none;' ng-src="{{idealImage.imgPath}}" width="90" height="70">
          <div class="product_thumb" style="background-image: url('{{idealImage.imgPath}}');display: none;"></div></a>
          </div>
         <span class='left_img_ind_count'><b class="badge-count-small badge">{{idealImage.imgQuan}}</b></span></li> </ul>

注意:这基本上是用指令显示图像拇指和缩放。

好吧,让我们看看,你循环了100个项目,对于每个项目,你添加了一个超时为100毫秒的指令,因此你基本上在处理过程中添加了10秒的超时。为什么Firefox不警告您长时间运行的脚本?在这种情况下,$timeout的目的是什么?两个目的。1-必须将元素添加到html中(否则指令不会应用于元素),2-我试图在设置的时间间隔后对处理进行排队,以避免这些停止脚本问题。首先,我不确定$timeout与向html添加内容有什么关系,其次,$timeout不会“排队”处理,这只会让脚本花费更长的时间。如果脚本错误发生在添加$timeout之前,您可能会显示整个过程,而不仅仅是这个指令位……我编辑我的问题,并提供添加指令的html元素,指令方法。好吧,让我们看看,您循环了100个项,对于每个项,您添加了一个超时为100毫秒的指令,因此实际上是在为处理添加10秒的超时。为什么Firefox不警告您长时间运行的脚本?在这种情况下,$timeout的目的是什么?两个目的。1-必须将元素添加到html中(否则指令不会应用于元素),2-我试图在设置的时间间隔后对处理进行排队,以避免这些停止脚本问题。首先,我不确定$timeout与向html添加内容有什么关系,其次,$timeout不会“排队”处理,这只会让脚本花费更长的时间。如果脚本错误发生在添加$timeout之前,也许您可以显示整个过程,而不仅仅是这个指令位……我编辑我的问题,并提供添加指令的html元素,指令方法。
global.leftBarAddClassicIdeal = function (size, product_type, li_id,_rootScope,_index) {
//console.log(size, product_type, li_id);
console.log(_rootScope.imgList,"IMGS")
var product_type = product_type;
var product_size = size;

//var li_width = '100'
//var li_height = '120';
var product_data = [];
product_data['frame_width'] = cart_sizes[product_type.toLowerCase()].inner_width;
product_data['frame_height'] = cart_sizes[product_type.toLowerCase()].inner_width;

product_data['product_type'] = product_type;
product_data['product_size'] = product_size;
product_data['container_l_margin_top'] = 30;
 angular.element('#' + li_id).css({width: cart_sizes[product_type.toLowerCase()].outer_width, height: cart_sizes[product_type.toLowerCase()].outer_height});

    var pic_real_width, pic_real_height;
    product_data['li_id'] = li_id;       
    product_data['pic_real_width'] = _rootScope.currentCart[product_type].data[_index].imgWidth;
    product_data['pic_real_height'] = _rootScope.currentCart[product_type].data[_index].imgHeight;
    global.setProductLayout(product_data, 'home',_rootScope);
  }