How to create a new empty list by clicking "new list"

0

Good afternoon,

I have an array of objects and display them in a list, in the list there is an input to insert new objects. I want to make a button where I would create a new list that is zeroed and with the same input to insert new objects. What would you do to make the lists display only the objects that were inserted in it?

I'm doing with AngularJs and I'm not able to create this new list, it pulls objects from the other too.

Does anyone have any tips for me to implement this list?

    
asked by anonymous 01.02.2016 / 17:52

1 answer

1

If I understood your problem, you accidentally stumbled upon one of the most interesting features of AngularJS: A capacidade de manter um escopo bindado mesmo quando você muda ele de lugar .

The quick answer is: Use angular.copy() to copy your list to a new place, so AngularJS creates a new item in your scope without linking your copy to the previous scope.

If you are interested in seeing an example of how to use angular.copy () in a similar application with the one you are mounting, see this plnkr that I put together. I put several comments in the code to help you understand the logic.

I've used this pattern of projects to assemble the code for this example. The standard in question was developed by a guy named John Papa and is maintained by a gigantic community, which includes Google professionals.

    
03.02.2016 / 17:38