我在我的应用程序中选择了所有功能。我在循环中至少有100个项目可供选择。我得到每个项目并添加到单独的$ rootScope变量中,该变量用于li元素的ng-repeat。在这个元素中我还添加了“mydirective”来执行一些渲染。这将在Firefox上生成Stop脚本问题。
在指令渲染中执行$ 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>
指令方法
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);
}
注意:这基本上是显示图像大拇指和带指令的缩放。