I'm in need of a solution for my form where each input creates a new object. Currently, I have a method that adds new objects without assigning unique IDs. Can anyone suggest an Angular approach to generate IDs for these objects?
$scope.addToDoItem = function(){
var toDoItems = $scope.toDoItems;
var newToDoItem = {
"id" : // id should be generated here
"content" : $scope.toDoItem,
"createdAt" : Date.now()
}
toDoItems.push(newToDoItem);
ls.set("toDoData", toDoItems);
$scope.toDoItem = "";
};
This is the view:
<form>
<input type="text" ng-model="toDoItem">
<input type="submit" ng-click="addToDoItem()">
</form>