Closed janober closed 9 years ago
Anybody anything?
Hey @janober —
Thanks for your patience on this. I just tried out your code and there were a couple of issues:
delete $scope.nodes[1];
was doing some funky stuff to your array. It was still being considered an array of length 3, though it was missing the key 1
(only had 0 and 2.) Angular was still ng-repeating 3 items, but the second one was undefined. Rather than tangle with this, I would recommend using $scope.nodes.splice(1, 0)
, which will remove from the array (in place) one element at index 1 and correctly updates the array to know that its new length is two, updating subsequent indexes appropriately.Here's a modified version of your code that works for me:
<fa-app style="width: 320px; height: 568px; overflow: hidden;">
<fa-modifier ng-repeat="node in nodes" fa-translate="[10,500]" fa-size="[80, 40]">
<fa-surface>
<button ng-click="remove()">Remove one</button>
</fa-surface>
</fa-modifier>
<fa-modifier ng-repeat="node in nodes" fa-translate="node.position" fa-size="[80, 40]">
<fa-draggable fa-pipe-from="node.handler">
<fa-surface fa-background-color="'red'" fa-size="[undefined, undefined]" fa-pipe-to="node.handler">
{{node.id}}: {{node.name}}
</fa-surface>
</fa-draggable>
</fa-modifier>
</fa-app>
Controller:
angular.module('integrationApp')
.controller('TestCtrl', function ($scope, $famous) {
var EventHandler = $famous['famous/core/EventHandler'];
var data = [];
data.push( {id: 0, name: 'zero', position: [10, 100], handler: new EventHandler() } );
data.push( {id: 1, name: 'one', position: [10, 200], handler: new EventHandler() } );
data.push( {id: 2, name: 'two', position: [10, 300], handler: new EventHandler() } );
$scope.nodes = data;
console.log($scope.nodes);
$scope.remove = function() {
$scope.nodes.splice(0, 1);
console.log($scope.nodes);
}
});
Hi Zack,
Thanks for the answer. Sadly does not work for me. The reason is that the above was just a simplified version. I am actually using an object not an array. But I just tested also with an array and because I had the same issue with both of them I thought it does not really matter which I use.
About the pipe-to. The problem is that I sadly need the pipe-to on the draggable because I need the "update" event from the draggable. So simply removing it does not work for me. Is related to the old issue #172 I had.
Hello Jan,
I had the same issue when $destroy is called on a Draggable, from deleting an item in a ng-repeat or from ui-router. It appears that it goes through $destroy without testing if it's a modifier so it tries to renderNode.unpipe(EventHandler). I've corrected this by testing it again before updating the pipes on https://github.com/SuPenguin/famous-angular/commit/c7f19cd9e4ae904f1c6c34d848c91c49da24f0e6.
It may be a better way of doing this, i'll submit a pull request if i find one.
Same issue, however I think fa-pipe-to on fa-draggable works for me, it is emitting the correct events.
@zackbrown Also I think $scope.nodes.splice(1, 0)
doesn't remove the element since the second argument is 0. Are you sure this is the right?
@SuPenguin your patch works, can you submit as a push request?
Awesome, thanks
@janober Is this still a valid issue? Thanks - Jordan
Very sorry. Was working on another project the last months, so did not really check back here. I am actually just starting with this now again.
First, thanks a lot for everybody who worked on it! I just tested and it works fine now. So close it.
Sorry have again a pipeing issue.
When I diplay multiple items with ng-repeat and then remove one, I get the following error message:
This only happens when I use "fa-pipe-to" on the draggable. I tried to unpipe manually before removing the item but got the same. But not sure if I did it correctly. Would be great to get a tipp how to avoid that and implement that correctly. Thanks!
The example bellow is on the basis of the draggable famous-angular-example.
JavaScript Code:
HTML Code: