【发布时间】:2014-02-24 13:57:02
【问题描述】:
我正在向 Firebase 列表添加新的子级,并且会自动创建唯一 ID。我需要某种方法来获取已创建的 ID,以便我可以立即将 URL 位置路径更改为包含该 ID 的路由。以下是我创建列表项的方式:
.controller('NewTestCtrl', ['$scope', 'syncData', '$location', function($scope, syncData, $location) {
$scope.newTitle = null;
$scope.tests = syncData('tests');
$scope.createTest = function() {
var newDate = new Date();
if( $scope.newTitle ) {
$scope.tests.$add({
title: $scope.newTitle,
createdDate: newDate,
modified: newDate,
user: $scope.auth.user.uid
});
$location.path("/test/" + [FIREBASE UNIQUE ID] + "/1");
}
};
}])
感谢您的帮助!
【问题讨论】:
标签: angularjs firebase angularfire