ng-sortable icon indicating copy to clipboard operation
ng-sortable copied to clipboard

scope.itemScope.element.prop is not a function

Open loverdrive opened this issue 9 years ago • 2 comments
trafficstars

Hi, i'm implementing ng-sortable. This is my html:

<div as-sortable="dragOptions" ng-model="startDrag">
    <div id="{{startDrag[$index].id}}" class="draggable" ng-repeat="element in startDrag" data-as-sortable-item>
        <p data-as-sortable-item-handle>
            {{startDrag[$index].name}}
        </p>
    </div>
</div>

When i move the first element, it is sorted correctly. But when i move the second element (included the same previous element), it give me the error:

Uncaught TypeError: scope.itemScope.element.prop is not a function    [ng-sortable.js:718]

Have you any idea what could be the problem? Thank you!

loverdrive avatar Dec 09 '15 12:12 loverdrive

Hey fellow in misery, I’d just fumbled around with this as well and it turned out you mustn’t use element as the reference to an entry in your array. So, maybe use something like ng-repeat="elem in startDrag" instead.

Zemke avatar Oct 05 '17 16:10 Zemke

Thanks, @Zemke! We have this plugin implemented at multiple places in our project and it all works fine -- but this one new place I was trying to add it and it was behaving weirdly and throwing this issue.

Your comment saved me from going crazy 😊 Turned out, I was referring to our element as element 🤷

saurabhj avatar Dec 23 '20 05:12 saurabhj