3

Let's say you have a list of items that are rendered 3x per row, like:

<div ng-repeat="piece in fooService.get()" class="span3">

And you want to be able to sort them. The only way I have found is to wrap with:

<div ui-sortable>

Which works, but does not bind to the model.

What am I missing?

1
  • I think I am missing two things: (1) Binding via ng-model, (2) may not work using a service call to obtain data. Can't bind that way. The answer to this question may be more along the lines of a better approach to the problem. Commented Mar 20, 2013 at 4:36

1 Answer 1

2

You have to pass the ng-model as well: See the below fiddle i found googling:

http://jsfiddle.net/g/hKYWr/

Edit Reference: http://plnkr.co/edit/Bzjruq?p=preview

Sign up to request clarification or add additional context in comments.

7 Comments

Because I am using a service to obtain the data, I get: Error: Non-assignable model expression: fooService.get() (<div ng-model="fooService.get()" ui-sortable="" class="ng-scope">) ... I believe I am messing with two paradigms but don't quite have the solution figured out.
You can also do '$scope.pieces = $scope.fooService.get();' and then pass the ng-model="pieces"
Here is a link to a discussion on calling a function in ng-model groups.google.com/forum/#!topic/angular/Pef6LY2rT7g
"You can also do '$scope.pieces = $scope.fooService.get();' and then pass the ng-model="pieces"" - But that won't reflect the model held by the service. Seems there is no way around bringing the model to the controller.
Hey i found a plunker injecting service in the controller. Might be useful plnkr.co/edit/Bzjruq?p=preview
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.