error - Update username in firebase database using ionic v3
up vote
0
down vote
favorite
i want add username field in firebase, as all said we cant add direct username field in firebase. So i am trying to add via update method. Here i got code with this if i add value in code that way working but i don't know how can i add value via input.
file.ts
this.fAuth.auth.onAuthStateChanged(function(user) {
if (user) {
// Updates the user attributes:
user.updateProfile({ // <-- Update Method here
displayName: "Goku",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
// Profile updated successfully!
// "NEW USER NAME"
var displayName = user.displayName;
// "https://example.com/jane-q-user/profile.jpg"
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
}
});
file.html
<form [formGroup]="myForm">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="user.displayName"></ion-input>
</ion-item>
</form>
</ion-content>
please help me...
add a comment |
up vote
0
down vote
favorite
i want add username field in firebase, as all said we cant add direct username field in firebase. So i am trying to add via update method. Here i got code with this if i add value in code that way working but i don't know how can i add value via input.
file.ts
this.fAuth.auth.onAuthStateChanged(function(user) {
if (user) {
// Updates the user attributes:
user.updateProfile({ // <-- Update Method here
displayName: "Goku",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
// Profile updated successfully!
// "NEW USER NAME"
var displayName = user.displayName;
// "https://example.com/jane-q-user/profile.jpg"
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
}
});
file.html
<form [formGroup]="myForm">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="user.displayName"></ion-input>
</ion-item>
</form>
</ion-content>
please help me...
Hello, did you try my answer?
– Peter Haddad
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
i want add username field in firebase, as all said we cant add direct username field in firebase. So i am trying to add via update method. Here i got code with this if i add value in code that way working but i don't know how can i add value via input.
file.ts
this.fAuth.auth.onAuthStateChanged(function(user) {
if (user) {
// Updates the user attributes:
user.updateProfile({ // <-- Update Method here
displayName: "Goku",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
// Profile updated successfully!
// "NEW USER NAME"
var displayName = user.displayName;
// "https://example.com/jane-q-user/profile.jpg"
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
}
});
file.html
<form [formGroup]="myForm">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="user.displayName"></ion-input>
</ion-item>
</form>
</ion-content>
please help me...
i want add username field in firebase, as all said we cant add direct username field in firebase. So i am trying to add via update method. Here i got code with this if i add value in code that way working but i don't know how can i add value via input.
file.ts
this.fAuth.auth.onAuthStateChanged(function(user) {
if (user) {
// Updates the user attributes:
user.updateProfile({ // <-- Update Method here
displayName: "Goku",
photoURL: "https://example.com/jane-q-user/profile.jpg"
}).then(function() {
// Profile updated successfully!
// "NEW USER NAME"
var displayName = user.displayName;
// "https://example.com/jane-q-user/profile.jpg"
var photoURL = user.photoURL;
}, function(error) {
// An error happened.
});
}
});
file.html
<form [formGroup]="myForm">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="user.displayName"></ion-input>
</ion-item>
</form>
</ion-content>
please help me...
asked 2 days ago
user9088454
156
156
Hello, did you try my answer?
– Peter Haddad
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago
add a comment |
Hello, did you try my answer?
– Peter Haddad
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago
Hello, did you try my answer?
– Peter Haddad
2 days ago
Hello, did you try my answer?
– Peter Haddad
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
To take the value from the html, try the following:
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="displayName"></ion-input>
</ion-item>
<ion-item>
<button ion-button type="submit" [disabled]="myForm.invalid">Submit</button>
</ion-item>
</ion-list>
</form>
Then in the .ts, do the following:
ngOnInit()
{
this.myForm = this.fb.group({
displayName : ['', Validators.required],
});
}
onSubmit()
{
if(this.myForm.valid)
{
this.displayName = this.myForm.get('displayName').value;
console.log(this.displayName);
}
}
this.displayName will contain the value of the ion-input, do not forget to declare the property displayName under the class declaration.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
To take the value from the html, try the following:
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="displayName"></ion-input>
</ion-item>
<ion-item>
<button ion-button type="submit" [disabled]="myForm.invalid">Submit</button>
</ion-item>
</ion-list>
</form>
Then in the .ts, do the following:
ngOnInit()
{
this.myForm = this.fb.group({
displayName : ['', Validators.required],
});
}
onSubmit()
{
if(this.myForm.valid)
{
this.displayName = this.myForm.get('displayName').value;
console.log(this.displayName);
}
}
this.displayName will contain the value of the ion-input, do not forget to declare the property displayName under the class declaration.
add a comment |
up vote
0
down vote
To take the value from the html, try the following:
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="displayName"></ion-input>
</ion-item>
<ion-item>
<button ion-button type="submit" [disabled]="myForm.invalid">Submit</button>
</ion-item>
</ion-list>
</form>
Then in the .ts, do the following:
ngOnInit()
{
this.myForm = this.fb.group({
displayName : ['', Validators.required],
});
}
onSubmit()
{
if(this.myForm.valid)
{
this.displayName = this.myForm.get('displayName').value;
console.log(this.displayName);
}
}
this.displayName will contain the value of the ion-input, do not forget to declare the property displayName under the class declaration.
add a comment |
up vote
0
down vote
up vote
0
down vote
To take the value from the html, try the following:
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="displayName"></ion-input>
</ion-item>
<ion-item>
<button ion-button type="submit" [disabled]="myForm.invalid">Submit</button>
</ion-item>
</ion-list>
</form>
Then in the .ts, do the following:
ngOnInit()
{
this.myForm = this.fb.group({
displayName : ['', Validators.required],
});
}
onSubmit()
{
if(this.myForm.valid)
{
this.displayName = this.myForm.get('displayName').value;
console.log(this.displayName);
}
}
this.displayName will contain the value of the ion-input, do not forget to declare the property displayName under the class declaration.
To take the value from the html, try the following:
<form [formGroup]="myForm" (ngSubmit)="onSubmit()">
<ion-list>
<ion-item>
<ion-label floating>Username</ion-label>
<ion-input formControlName="displayName" type="text" [(ngModel)]="displayName"></ion-input>
</ion-item>
<ion-item>
<button ion-button type="submit" [disabled]="myForm.invalid">Submit</button>
</ion-item>
</ion-list>
</form>
Then in the .ts, do the following:
ngOnInit()
{
this.myForm = this.fb.group({
displayName : ['', Validators.required],
});
}
onSubmit()
{
if(this.myForm.valid)
{
this.displayName = this.myForm.get('displayName').value;
console.log(this.displayName);
}
}
this.displayName will contain the value of the ion-input, do not forget to declare the property displayName under the class declaration.
answered 2 days ago
Peter Haddad
19.5k83854
19.5k83854
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53350012%2ferror-update-username-in-firebase-database-using-ionic-v3%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Hello, did you try my answer?
– Peter Haddad
2 days ago
yes, i did but but not solve
– user9088454
2 days ago
what is the problem? Didn't you want to get the value from html to ts?
– Peter Haddad
2 days ago