Check out this Plunker for reference: http://plnkr.co/edit/2gD0AB. The Plunk seems to have an issue with the $scope.$on("$viewContentLoaded")
not firing, but it works fine on my end. Hopefully, you can still get the gist of what I'm trying to achieve.
My goal is to move field objects from $scope.fields
to
$scope.groupFields = [], $scope.listFields = [], $scope.dataFields = []
when dragging them to the designated drop areas. I've managed to accomplish this using jQuery UI and jQuery UI touch punch to ensure mobile compatibility.
If you drag elements from the fields box to the empty boxes, you'll notice no visual change until you inspect $scope.fields
with a console.log
in the drop
event listener, revealing that the field objects are correctly placed in their respective boxes.
Clicking the Add element button triggers console.log($scope.groupFields);
, causing all elements to appear correctly in their intended boxes as initially planned.
After struggling and researching extensively, I discovered that calling $scope.$apply()
after the moveField
function within the drop
event resolves the issue.
I'm puzzled by this solution. Shouldn't a digest process already be running to update the view based on controller actions?
Thank you!