我创建了一个用户可以登录并更新其个人资料的网页,
但按钮不起作用,它不会保存firebase中当前用户的数据,例如about和userImg in this picture
贝娄是我的代码
HTML:
<form class="Email-change">
<p class="text-typ">Email:</p>
<input type="email" ng-model="user.email" class="line">
<p class="text-typ">Username:</p>
<input type="text" ng-model="user.displayName">
<p class="text-typ">About:</p>
<input type="text" id="aboutMsg" ng-model="user.About">
<br>
<button class="change" id="aboutSubmit" onclick="updateAbout()">Change
information</button>
</form>
控制器:
app.controller('SignUpController', ['$scope', '$location', '$firebaseAuth',
function ($scope, $location, $firebaseAuth) {
$scope.signUp = function (user) {
console.log(user);
$firebaseAuth().$createUserWithEmailAndPassword(user.email,
user.password)
.then(function (fireUser) {
if (fireUser) {
var theUser = firebase.auth().currentUser;
theUser.updateProfile({
displayName: user.username
}).then(function () {
//om det är ok
}).catch(function (err) {
console.log(err);
});
firebase.database().ref('/users/' + fireUser.uid).set({
username: user.username
});
$location.path('/');
}
})
.catch(function (err) {
$scope.error = err.message;
});
};
}]);
的java:
`function updateAbout(){
alert('it works');
var firebaseRef = firebase.database().ref('users');
firebaseRef.child("About").set("I Love dancing");
console.log("I love dancing");
}`