$scope.phone isn't a valid property name literal. You could use "$scope.phone":
$scope.messages.$add({
"$scope.phone" : {
username: $scope.username,
email: $scope.email,
dob: $scope.dob
}
});
...but it will create a property with that actual name, which probably isn't what you want. Looking at that literal, I can't quite figure out from the names what you actually want, I can't quite make phone work in relation to the other field names.
Re your comment:
See this example: usersRef.set({ alanisawesome: { date_of_birth: "June 23, 1912", full_name: "Alan Turing" } Instead of alaniawesome I want to have phone as my key.
You can't do that in an object initializer, the property name part of the property initializers in it are always taken literally. You'll have to do it in two separate statements:
var obj = {};
obj[alanisawesome] = { date_of_birth: "June 23, 1912", full_name: "Alan Turing" };
usersRef.set(obj);
That works because in JavaScript, when accessing a property name outside of an object initializer, you can use either dot notation and a literal property name (obj.foo), or bracketed notation and a string property name (obj["foo"]). In the latter case, the string can be the result of any expression, including a variable reference.
$scope.phoneas key name$scope.phone. ;-)