1

I'm want to make some images sortable by dragging them around in my Angular website for which I'm trying to use angular-sortable-view. The demos look really good, but I just can't get it to work in my own code and I get no error whatsoever.

I've got a simple list defined in my controller:

$scope.prop = {};
$scope.prop.images = [
    {id: 'http://www.adiumxtras.com/images/thumbs/dango_status_icon_set_7_19047_6248_thumb.png'},
    {id: 'https://upload.wikimedia.org/wikipedia/commons/thumb/1/1f/Red_information_icon_with_gradient_background.svg/48px-Red_information_icon_with_gradient_background.svg.png'},
    {id: 'https://www.haiku-os.org/docs/userguide/images/apps-images/icon-o-matic-icon_64.png'},
];

and my html looks as follows:

<div sv-root sv-part="prop.images">
    <div ng-repeat="image in prop.images" sv-element>
        <img src="{{ image.id }}">
    </div>
</div>

I made a plunker here.

Does anybody know what I'm doing wrong? All tips are welcome!

2 Answers 2

4

You've got a couple problems here. The first being that angular-sortable-view is a separate module which you need to add to your app:

angular.module('sort', ['angular-sortable-view'])

In addition to that, since images are draggable in the browser, you must disable that:

<img draggable="false" ng-src="{{photo.id}}" />

Check the forked plunkr here: http://plnkr.co/edit/i8Z8jJGnJoGFgTMFej4Q?p=preview

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

Comments

1

According to https://github.com/kamilkp/angular-sortable-view to sort images you need to add draggable="false" atribute to your image:

<img draggable="false" ng-src="{{image.id}}">

Comments

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.