Reputation: 3
There is a way to set a $scope
variable as a key on Firease?
I've tried this:
xxx.$add({
$scope.xxxx.key: {
name: $scope.xxx.name,
age: $scope.xxx.age,
email: $scope.xxx.email,
}
});
But isn't work, there is way to do that?
Upvotes: 0
Views: 63
Reputation: 2188
You can build objects with dynamic property names in javascript like this:
var newEntry = {};
newEntry[$scope.xxxx.key] = {
name: $scope.xxx.name,
age: $scope.xxx.age,
email: $scope.xxx.email,
};
xxx.$add( newEntry );
Upvotes: 1