R
R
RodgerFox2015-07-17 06:20:42
Angular
RodgerFox, 2015-07-17 06:20:42

Mythical inheritance with respect to ng-repat, in angular. Which solution is correct?

Greetings!
While studying angular, on a previously created task, I encountered an extremely incomprehensible ( mythical ) data sequence.
The anomaly involved: angular 1.4, ui.sortable (convenient block sorting), textAngular (content editor).
There is a multidimensional array, we display it using ng-repeat. In each "instance" taken from the array, there is a field with the content of which it works, using textAngular'a. To add new blocks, I use the clone feature along with ui.sortable (for the drag drop effect), a close example(the whole point is in the identical ui-sortable="sortableOptions", for separate blocks. But when we take it from a specific block and drag it to the rest of the elements displayed through ng-repeat, we return it back through a preliminary copy of the selected element. i.e. copy the instance .)
Everything works great, as long as we don't edit the new instances moved into the main array. As you can already guess or not yet, the problem lies in the duplication of content on all copied blocks, although their own editors have been created for them, with their own unique identifiers, etc.
Where and how is it possible and necessary to track this metaphysical connection of already separate blocks?
The array is multidimensional and the blocks can and do have different "parents".
Thank you.
psRead the documentation for the editor. I'm not sure if the problem is related to it, maybe there is some kind of magic when I put a new object in the main array (with other objects)?

They asked to recreate the task: codepen.io/Velentin/pen/RPBxYw (at the bottom of the "New Element" block, it can and should be dragged to other blocks).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2015-07-17
@streetflush

Maybe I didn’t quite understand, but how is it possible to store 2 ID arrays and the main array with elements is used for display, like a reference table?
Those. you drag the unchanged number (id), and then mainArray[id] to display
Upd. - in vain I crucified
UpdUpd.
Replaced by:
$scope.newElem = angular.copy(copElem);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question