FWIW, arrays now have a native .filter function.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter

Dunno how much back-compat you need for that kind of thing.

e


On Tue, Jul 29, 2014 at 11:28 AM, Skattabrain <[email protected]> wrote:

> Thanks guys, I will look into underscore... I was hoping to not pull in
> another dependency, but it looks really good.
>
> So I have the comparison working by using forEach to look for it... this
> could be faster for certain.
>
> Sander, I know what you mean... but the requirement is to have all items
> loaded so we can filter instantly, and mass add/remove quickly. I'm using
> paging on Angular to show my lists (20 at a time) and that basically has
> incredible performance. I originally had all the items visible... but the
> filtering is instant as if there were 100 items, and the paging is smooth
> as well. With this many items, paging is just there to fill the
> requirement, I suspect users will b-line right to the filter.
>
> Luke, _diff looks like what I need.
>
>
> On Monday, July 28, 2014 3:40:42 PM UTC-4, Skattabrain wrote:
>>
>> AngularJS noob here with a design question.
>>
>> I have 2 lists... one is a list of items for a specific group. Let's call
>> the group "My Items". The 2nd list is a master list of all the items
>> available - "Available Items".
>>
>> This 2nd list can be changed out for other lists. So you might have
>> "Available Items of Type 1" and "Available Items of Type 2" etc...
>>
>> I show the "Available Items" on the left and the "My Items" on the right.
>>
>> If you visualize a shopping cart system where the available items are on
>> left and you are moving them into your "cart", that's a good way to
>> visualize this.
>>
>> $scope.myItems = []
>> and
>> $scope.availableItems = []
>>
>> So I start off with 2 ajax calls... 1 for 'my items' and the 2nd call
>> gets the currently selected 'available items' lists.
>>
>> The available items on the left may include items that are in 'my list'
>> but they should not be shown. I have a relatively in-efficient loop I run
>> through to see if the item is in "my items" and if it isn't, I push it to
>> the scope - $scope.availableItems
>>
>> There is the issue that the 'myItems' list has to be completed before i
>> call for the availableItems in case myItems isn't complete... as the
>> comparison will not be right.
>>
>> I then have tools to move selected items in and out of the myItems.
>>
>> Is there a better way though the use of a directive that will watch for
>> changes to myItems and remove/add them to the availableItems?
>>
>> I've been dropped into AngularJS with a relatively complicated task.
>> These lists involve thousands of items and we chose angular because i can
>> throw 15,000 items into a scope and as long as I have paging setup... i can
>> filter and sort the whole thing easily, that's working amazingly well.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to