I have lots of JS arrays like the following:
q = [{
"v": "blah",
"t": "asdfsdf",
}, {
"v": "basldfasdfd",
"t": "blah",
}...]
I'd like to assign unique id's to them, and then attach those id's to buttons, essentially. However, I'm not sure where I should put the id's without changing the structure of the JS array. I'm building an angular JS app and in the chrome dev tools, I've noticed a $$hashkey
for each element. Does the entire array have a property like that? If so, how can I use it, and will it change if the array changes (which it will)?
I'd like to avoid further nesting, ie, I'd prefer to avoid having to do something like
q = {
data: [whatever was above],
meta: { id: 234234324, ... }
};
Is that the only way? If so, then in AngularJS, instead of doing ng-repeat="item in q"
, I would just do ng-repeat="item in q.data"
, right?