skip to Main Content

Javascript – How to implement subscribe synchronously like async await. angular, firebase

the problem is that the console represent 'undefined'. this.firestore.collection('list').doc('1').get().subscribe((doc: any) => { this.myAns = doc.data().answer ? doc.data().answer : "no answer"; }); console.log('this.myAns', this.myAns); but, I want to get right answer in console. this.firestore.collection('list').doc('1').get().subscribe(async (doc: any) => { this.myAns = await…

VIEW QUESTION

Javascript – how to prevent special charactors in ion-input .?

special characters are accepting in input field . i am using the field for storing the serial number. serial number is alphanumeric <ion-input [(ngModel)]="serial_number" (ngModelChange)="validation($event)" #serialno id="serialno" class="cac-input"></ion-input> validation(event) { const inputElement = document.getElementById('serialno') as HTMLInputElement; const pattern = /^[a-zA-Z0-9]*$/;…

VIEW QUESTION
Back To Top
Search