Skip to content Skip to sidebar Skip to footer

AngularJS Set Dynamic Key In Array Element

I have trouble to set dynamic array key. Here is my code, HTML

Solution 1:

If you only want the keys that have been set to exist in the data you send to your server, then use an object instead of an array. like so:

$scope.newName = {};

Instead of:

$scope.newName = [];

This way, what's sent to the server would be:

{
    12: "Input value",
    15: "Input value"
}

I hope this is what you're looking for.


Post a Comment for "AngularJS Set Dynamic Key In Array Element"