好的家伙,所以我有这个代码,它告诉我Firebase.set();失败(极简代码):
$scope.$evalAsync(
function() {
var letterAvatar = letterAvatarService.getLetterURL($scope.register.username);
setTimeout(function() {
refService.ref().child("UserAuthInfo").child(userData.uid).set({
Username: $scope.register.username,
Email: $scope.register.email,
UID: userData.uid,
Image: letterAvatarService.getLetterURL($scope.register.username),
Moderator: false,
BronzeBadge: 0,
SilverBadge: 0,
GoldBadge: 0,
PlatinumBadge: 0,
newUser: true,
profileBackground: 'http://rmdeaftheatre.com/wp-content/uploads/2012/11/gray-background-3.jpg',
followers: 0,
following: 0,
profileViews: 0,
Precence: -1,
});
}, 1500)
alertify.success("Sucessfully Registered")
}
);
正如你所看到的,我把$ evalAsync放在那里,但是这些出现(对于视觉效果):
这是我的服务代码(完整版):
(function(angular){
var app = angular.module('ForumApp')
app.service('letterAvatarService', ['$http',letterAvatarServiceFunc])
function letterAvatarServiceFunc($http){
this.getLetterURL = function(string){
$http.get('services/assets/json/letterJSON.json').then(function(value) {
this.letters = value.status;
var char = string.charAt(0);
var len = 0;
var lenNum = 0;
var URLVALUE = '';
for(var i in value.data.letters){
len++;
if(i == (char.toLowerCase())){
URLVALUE = value.data.letters[i].URL;
}
}
for(var i in value.data.numbers){
lenNum++;
if(i == (char)){
URLVALUE = value.data.numbers[i].URL;
}
}
if(!URLVALUE){
URLVALUE = value.data.Mystery
}
console.log(URLVALUE);
});
}
}
})(angular);
请帮助。