我正在使用Angularfire创建数组,但我无法设置密钥名称.Firebase会自动给我一个神秘的密钥(例如Jm9vLy8Lye-KS35KsmL),但我想把它自己设置为更有意义的东西.目前还不清楚我是如何在Angularfire中做到这一点的.我在$ firebaseArray上使用$ add方法:
var firebaseRef = new Firebase("https://firebase_location");
$scope.messages = $firebaseArray(firebaseRef);
$scope.messages.$add(
{
FirstName: patient.FirstName,
LastName: patient.LastName
}
).then(function(firebaseRef) {
var id = firebaseRef.key();
});
Run Code Online (Sandbox Code Playgroud)
数据存储得很好,我可以在仪表板上看到它.但是,id始终是一个神秘的火力值.我希望能够将自己设定为有意义的东西.在我的情况下,个别患者的ID将是有意义的...
有什么想法吗?
谢谢!