angularjs - prepend key to javascript object -


i receiving data filled in form, before posting server need prepend key

> data object {rate: "300", identifier: "zda"} 

then need generate unique key such "otnmam1jukm=". key generated function like:

key = generatekey(); 

and prepend object end with

object {"otnmam1jukm=": {rate: "300", identifier: "zda"}} 

any appreciated... please note using angular in ionic cross platform app.

var newdata = {}; newdata[generatekey()] = data; 

you can use expressions when use [].


Comments