AngularJS track by expression for lists that can add and remove items

Is there a nice way to use the track by feature for ng-repeat with editable lists, i.e. lists where the user can remove and add items to?

Existing objects already have a unique ID assigned while a missing ID is my marker to create that item on form submission.

Using track by $index would work as long as the user only adds elements to the list. Using track by myId would work as long as the user only deletes or changes items in the list.

The only way I can see to realize that behavior is assigning a temporary random ID to a property of every new item and have a scope method which returns either the real or the temporal ID, whatever exists. Seems not so elegant...

As I can imagine this is a rather common use case, are there more elegant ways to handle this?


I often add a property cid (client-id) to my models. I assign the property when I fetch the models or create a new one so that every model has a cid. Then I can do something like:

<li ng-repeat="for item in list track by item.cid">{{ }}</li>

Need Your Help

How can I read a Google Spreadsheets using jquery and php

php jquery

I have some information in Google Spreadsheets as a single sheet. Is there any way by which I can read this information from html by jquery and php. my sheet link and my username

Recursive Binary Search Tree Deletion

java algorithm recursion tree

Note: I've included the code for the insert in case that is where my error lies.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.