Angular drag and drop - how to pass parameter to onStart callback function

SITUATION:

I have an application that uses angular drag and drop .

Everything is working fine, except for one. I need to pass one parameter to the onStart callback function, but I don't know how to do this. I search around and try several possibilities, but to no avail. The function itself works, has been called and executed properly, the only problem I have is to pass a parameter to it.

CODE:

In this example, there is one of the attempts that I made.

<div class="col-sm-4"> <div class="thumbnail" data-drop="true" ng-model='todo_list' jqyoui-droppable="{multiple:true, onDrop:'update_item()'}"> <div class="caption"> <div class="btn btn-info btn-draggable" ng-repeat="item in todo_list track by $index" ng-show="item.title" data-drag="true" data-jqyoui-options="{revert: 'invalid'}" ng-model="todo_list" jqyoui-draggable="{index: {{$index}}, onStart:'set_board_item_id_panel(event, ui, {board_item_id: item.board_item_id})'}">{{item.title}}</div> </div> </div> </div> 

QUESTION:

How can I pass a parameter to an angular drag and drop callback function?

Thank you very much!

+6
source share
1 answer

You do not need to pass event and ui parameters, these are the first two arguments by default.

Replace ...

 onStart:'set_board_item_id_panel(event, ui, {board_item_id: item.board_item_id})' 

WITH...

 onStart:'set_board_item_id_panel({board_item_id: item.board_item_id})' 

Then in your controller do this ...

 .... $scope.set_board_item_id_panel = function (event, ui, board_item_id) { console.log(board_item_id); } .... 
+9
source

Source: https://habr.com/ru/post/980303/


All Articles