简体   繁体   English

在ng-repeat angular spin.js中为多个项目加载微调器

[英]Load spinner for multiple items in ng-repeat angular spin.js

Plunker here: http://plnkr.co/edit/das1We3T9hY39x8R?p=preview 在这里柱塞: http ://plnkr.co/edit/das1We3T9hY39x8R?p=preview

I have a list of items in my ng-repeat. 我的ng-repeat中有项目清单。

When one of these items is clicked/selected, They're removed from the left column and added to the right column. 单击/选择这些项目之一时,会将它们从左列中删除,然后添加到右列中。 As they are placed in the right column a spinner should show. 当它们放置在右栏中时,微调器将显示。

I've not been able to get it to work as it does on my local build within the plunker but my specific problem is that the spinner only kicks off when the first item in the list is clicked. 我无法像在plunker中的本地版本上那样使它正常工作,但是我的特定问题是微调器仅在单击列表中的第一项时才会启动。

It sort of behaves similarly in the plunker in that if you click the second item first and then the second, the spinner shows. 如果您先单击第二个项目,然后单击第二个项目,则微调器将显示类似的行为。 However I need one spinner to show per item every time it is moved to the right column. 但是,我需要一个微调器来显示每个项目,每次将其移到右侧列时。

It must have something to do with the userState-{{$index}} and 'userState-'+user.id below 它必须与下面的userState-{{$ index}}和'userState-'+ user.id有关

<li class="pull-right">
   <div dw-loading="userState-{{$index}}" 
        dw-loading-options="{overlay: true, text: '', 
           spinnerOptions: {length: 6, width:3, radius: 6}}">
       <a href="" ng-click="remove(sUser)">
          <i class="glyphicons remove inline"></i></a>
    </div>
 </li>




$scope.loadUsers = function(user) {
       $loading.start('userState-'+suspect.id);
   $timeout( function() {
           $loading.finish('userState-'+user.id);
       }, 3000)

     };

Thanks! 谢谢!

I took a look at the issue, and also looked at the directive you were using for loading. 我研究了这个问题,还研究了用于加载的指令。 From my quick overview, it looks like this directive is used around an ng-repeat rather than on each element that has been repeated. 从我的快速概述中可以看出,此指令似乎在ng-repeat周围使用,而不是在已重复的每个元素上使用。

I updated your plunk here with it working like that: http://plnkr.co/edit/MDqfWxssNftGlwmC5WZE?p=preview 我在这里用这样的方式更新了您的插件: http : //plnkr.co/edit/MDqfWxssNftGlwmC5WZE?p=preview

I moved the loading directive outside the ng-repeat like this: 我将加载指令移动到ng-repeat外部,如下所示:

<div dw-loading="sSuspectLoading" dw-loading-options="{overlay: true, text: '', spinnerOptions: {length: 6, width:3, radius: 6}}" class="">
    <div ng-repeat="sSuspect in selectedSuspects" class="top-buffer">
        <!-- Repeated content here -->
    </div>
</div>

Then I just modified the load start/end to call that instead: 然后,我只是修改了加载开始/结束以调用它:

$loading.start('sSuspectLoading');
$timeout( function() {
    $loading.finish('sSuspectLoading');
}, 3000);

If you're wanting the loader on each individual item as opposed the entire ng-repeat, I think you're going about it the wrong way using this directive as it doesn't look like it's designed for that (from my quick observations). 如果您要在每个单独的项目上使用加载程序,而不是整个ng-repeat,我认为您使用该指令的方式是错误的,因为它看起来并不是为此而设计的(根据我的快速观察) 。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM