Plz help me with this.
http://jsfiddle.net/aeSaJ/141/
On Sunday, March 24, 2013 8:11:10 AM UTC+8, Matt Raible wrote:
>
> Figured it out.
>
> <button ng-click="moveUp(selected[0], items)">Move Up</button>
> <button ng-click="moveDown(selected[0], items)">Move Down</button>
>
> select size=10 ng-model="selected" ng-options="i.title for i in
> items" multiple="multiple"></select>
>
> And in my controller:
>
> $scope.moveUp = function(item, list) {
> var idx = list.indexOf(item);
> if (idx != -1) {
> list.splice(idx - 1, 0, list.splice(idx, 1)[0]);
> }
> };
>
> $scope.moveDown = function(item, list) {
> var idx = list.indexOf(item);
> if (idx != -1) {
> list.splice(idx + 1, 0, list.splice(idx, 1)[0]);
> }
> };
>
> Hope this helps someone in the future.
>
> On Mar 23, 2013, at 1:32 PM, Matt Raible <[email protected] <javascript:>>
> wrote:
>
> This works great for moving items between two selects. Do you have
> something similar for re-ordering the items in the select?
>
> On Saturday, June 16, 2012 8:51:17 AM UTC-6, Andy Joslin wrote:
>>
>> You can do it pretty simply: http://jsfiddle.net/andytjoslin/aeSaJ/3/
>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "AngularJS" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/angular/cyw1j3iarNc/unsubscribe?hl=en-US
> .
> To unsubscribe from this group and all its topics, send an email to
> [email protected] <javascript:>.
> To post to this group, send email to [email protected] <javascript:>
> .
> Visit this group at http://groups.google.com/group/angular?hl=en-US.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
--
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.