Aman Joshi Aman Joshi - 2 years ago 114
AngularJS Question

How to access dynamic key value in object key angularjs

var value = attr.inlineEdit;
var field = value.substring(11);

//Here I have first_name in field variable

user.hit({field : scope.model}, auth.getCurrentUser().user_id)
.success(function () {

in the field key I want that should be have first_name when i have first_name in field variable but I'm getting only field as a key

It's weired but i need to do something on it

Answer Source

I think {[field]: scope.model} is what you actually want.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download