热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

求大神来看看我的bug什么原因

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302




   

   

       


           


                   

                   

                   


  •                    


                           


                               


                                   

                                   

                               


                           


                           


                               


                               


                               


                           


                           


                               

                                   

                                   

                               


                           


                       


                   


  •                

               


       


       


           


                   


  •                    


                           


                               


                                   


                                       


                                           

                                           

                                       


                                   


                               


                           


                            all

                       


                   


  •            


       


   


   







//script

function MessageCenterController($scope, $timeout, $filter) {

    'ngInject';



    $scope.tabs = [

        {

            heading: "通知",

            messages: [

                {

                    type: 'invitation',

                    from: {

                        name: 'Janny'

                    },

                    brief: 'say hello',

                    id: '0001'

                },{

                    type: 'task',

                    from: {

                        name: 'Hokinson'

                    },

                    brief: 'say hello',

                    id: '0002'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Gray'

                    },

                    brief: 'say hello',

                    id: '0003'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Dammy'

                    },

                    brief: 'say hello',

                    id: '0004'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Jasmin'

                    },

                    brief: 'say hello',

                    id: '0005'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Tommy'

                    },

                    brief: 'say hello',

                    id: '0006'

                },{

                    type: 'invitation',

                    from: {

                        name: 'John'

                    },

                    brief: 'say hello',

                    id: '0007'

                },{

                    type: 'invitation',

                    from: {

                        name: 'lulu'

                    },

                    brief: 'say hello',

                    id: '0008'

                },{

                    type: 'invitation',

                    from: {

                        name: 'May'

                    },

                    brief: 'say hello',

                    id: '0009'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Amy'

                    },

                    brief: 'say hello',

                    id: '0010'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Kim'

                    },

                    brief: 'say hello',

                    id: '0011'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Lily'

                    },

                    brief: 'say hello',

                    id: '0012'

                },{

                    type: 'invitation',

                    from: {

                        name: 'Ann'

                    },

                    brief: 'say hello',

                    id: '0013'

                }

            ]

        },{

            heading: "待处理",

            messages: []

        }

    ];



    $scope.messageTransform = function($event, message, idx) {

        let index, indexInSelected;

        switch (idx) {

            case 0:

                index = findMessageIndex(message.id, $scope.tabs[0].messages);

                $scope.tabs[0].messages.splice(index,1);

                indexInSelected = findMessageIndex(message.id, selectedMessages);

                if(indexInSelected >= 0) {

                    selectedMessages.splice(index,1);

                }

                $scope.tabs[1].messages.unshift(message);

                break;

            case 1:

                indexInSelected = findMessageIndex(message.id, selectedPendings);

                if(indexInSelected >= 0) {

                    selectedPendings.splice(index,1);

                }

                index = findMessageIndex(message.id, $scope.tabs[1].messages);

                $scope.tabs[1].messages.splice(index,1);

                $scope.tabs[0].messages.unshift(message);

                break;

        }

    };



    var selectedMessages = [];

    var selectedPendings = [];



    $scope.updateChecked = function($event, item, idx) {

        let target = angular.element($event.target).siblings('input');

        let action = target.attr('checked') ? "remove" : "add";

        $scope.updateSelected(action, item, idx);

    };



    $scope.updateSelected = function(action, selection ,idx) {

        let result, index;

        switch (idx) {

            case 0:

                if(action === "add") {

                    if(selection.cOnstructor=== Array) {

                        for(let i=0;i<$scope.tabs[0].messages.length;i++) {

                            result = $filter('filter')(selectedMessages, {id: $scope.tabs[0].messages[i].id});

                            if(result.length == 0) {

                                selectedMessages.push($scope.tabs[0].messages[i]);

                                result = undefined;

                            }

                        }

                    } else {

                        selectedMessages.push(selection);

                    }

                }

                else if(action === "remove") {

                    if(selection.cOnstructor=== Array) {

                        selectedMessages.splice(0, selectedMessages.length);

                    } else {

                        for(let i=0;i
                            if(selectedMessages[i].id == selection.id) {

                                index = i;

                                break;

                            }

                        }

                        selectedMessages.splice(index,1);

                    }

                }

                break;

            case 1:

                if(action === "add") {

                    if(selection.cOnstructor=== Array) {

                        for(let i=0;i<$scope.tabs[1].messages.length;i++) {

                            result = $filter('filter')(selectedPendings, {id: $scope.tabs[1].messages[i].id});

                            if(result.length == 0) {

                                selectedPendings.push($scope.tabs[1].messages[i]);

                                result = undefined;

                            }

                        }

                    } else {

                        selectedPendings.push(selection);

                    }

                }

                else if(action === "remove") {

                    if(selection.cOnstructor=== Array) {

                        selectedPendings.splice(0, selectedPendings.length);

                    } else {

                        for(let i=0;i
                            if(selectedPendings[i].id == selection.id) {

                                index = i;

                                break;

                            }

                        }

                        selectedPendings.splice(index,1);

                    }

                }

                break;

        }

    };



    $scope.isSelected = function(id, idx) {

        let result;

        switch (idx) {

            case 0:

                result = $filter('filter')(selectedMessages, {id: id});

                if(result.length === 0) {

                    return false;

                } else {

                    return true;

                }

                break;

            case 1:

                result = $filter('filter')(selectedPendings, {id: id});

                if(result.length === 0) {

                    return false;

                } else {

                    return true;

                }

                break;

        }

    };



    $scope.isAllSelected = function(idx) {

        switch (idx) {

            case 0:

                if(selectedMessages.length == $scope.tabs[0].messages.length && selectedMessages.length != 0) return true;

                else return false;

                break;

            case 1:

                if(selectedPendings.length == $scope.tabs[1].messages.length && selectedPendings.length != 0) return true;

                else return false;

                break;

        }

    };



    function findMessageIndex(id, messages) {

        for(let i=0; i
            if(messages[i].id === id) {

                return i;

            }

        }

        return -1;

    }

}

整体的功能是这样的:
有左右两个tab页,左边的是“通知”,右边的是“待处理”(即稍后处理的意思)。
通知里的列表项目右上角有个按钮,点击之后该条项目会被移到待处理里;待处理里也同理可以将消息转回通知里。
列表下方有一个全选按钮,能实现全选操作。

问题1:只要鼠标进入li.message-item范围内就不停地触发判断ng-checked,该怎么解决呢?
问题2:触发messageTransform()后,列表项数量马上发生了变化,但是整个列表的高度卡顿了一下才变化。
问题3:触发messageTransform()时,有时候会对其他列表项的ng-checked造成影响。

初学angularjs,函数可能写得惨不忍睹,希望大家多多指教!


推荐阅读
  • 网址:https:vue.docschina.orgv2guideforms.html表单input绑定基础用法可以通过使用v-model指令,在 ... [详细]
  • 前景:当UI一个查询条件为多项选择,或录入多个条件的时候,比如查询所有名称里面包含以下动态条件,需要模糊查询里面每一项时比如是这样一个数组条件:newstring[]{兴业银行, ... [详细]
  • 先看看ElementUI里关于el-table的template数据结构:<template><el-table:datatableData><e ... [详细]
  • 深入解析Linux下的I/O多路转接epoll技术
    本文深入解析了Linux下的I/O多路转接epoll技术,介绍了select和poll函数的问题,以及epoll函数的设计和优点。同时讲解了epoll函数的使用方法,包括epoll_create和epoll_ctl两个系统调用。 ... [详细]
  • OpenMap教程4 – 图层概述
    本文介绍了OpenMap教程4中关于地图图层的内容,包括将ShapeLayer添加到MapBean中的方法,OpenMap支持的图层类型以及使用BufferedLayer创建图像的MapBean。此外,还介绍了Layer背景标志的作用和OMGraphicHandlerLayer的基础层类。 ... [详细]
  • javascript  – 概述在Firefox上无法正常工作
    我试图提出一些自定义大纲,以达到一些Web可访问性建议.但我不能用Firefox制作.这就是它在Chrome上的外观:而那个图标实际上是一个锚点.在Firefox上,它只概述了整个 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • 本文介绍了Perl的测试框架Test::Base,它是一个数据驱动的测试框架,可以自动进行单元测试,省去手工编写测试程序的麻烦。与Test::More完全兼容,使用方法简单。以plural函数为例,展示了Test::Base的使用方法。 ... [详细]
  • 计算机存储系统的层次结构及其优势
    本文介绍了计算机存储系统的层次结构,包括高速缓存、主存储器和辅助存储器三个层次。通过分层存储数据可以提高程序的执行效率。计算机存储系统的层次结构将各种不同存储容量、存取速度和价格的存储器有机组合成整体,形成可寻址存储空间比主存储器空间大得多的存储整体。由于辅助存储器容量大、价格低,使得整体存储系统的平均价格降低。同时,高速缓存的存取速度可以和CPU的工作速度相匹配,进一步提高程序执行效率。 ... [详细]
  • 不同优化算法的比较分析及实验验证
    本文介绍了神经网络优化中常用的优化方法,包括学习率调整和梯度估计修正,并通过实验验证了不同优化算法的效果。实验结果表明,Adam算法在综合考虑学习率调整和梯度估计修正方面表现较好。该研究对于优化神经网络的训练过程具有指导意义。 ... [详细]
  • 本文详细介绍了如何使用MySQL来显示SQL语句的执行时间,并通过MySQL Query Profiler获取CPU和内存使用量以及系统锁和表锁的时间。同时介绍了效能分析的三种方法:瓶颈分析、工作负载分析和基于比率的分析。 ... [详细]
  • 本文介绍了如何使用Express App提供静态文件,同时提到了一些不需要使用的文件,如package.json和/.ssh/known_hosts,并解释了为什么app.get('*')无法捕获所有请求以及为什么app.use(express.static(__dirname))可能会提供不需要的文件。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • Python中的PyInputPlus模块原文:https ... [详细]
author-avatar
孙誉嘉两_365
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有