Questions tagged [angular-promise]
Angular's $q promises provide a powerful abstraction over flow control. If you tag your question with this tag, consider also tagging it with "promise" tag. This tag is also appropriate for questions about angular and promises not relaying to $q directly.
2,117
questions
0
votes
2
answers
101
views
How to change an observable http request to promise request
This is my service file
This is my components ts file
And these are response models
I am having issues with displaying the data I'm fetching through an Observable-based service in my TypeScript ...
0
votes
0
answers
62
views
In Angular, how can I wait a function finish before execute a post petition that returns an observable?
I need to generate a Google reCAPTCHA V3 token and send it on the body of my post petition. Something like this:
let body = {}
@Injectable({
providedIn: 'root'
})
export class SujetoObligadoService ...
0
votes
1
answer
111
views
Angular: RouterGuards, HTTP requests and race conditions
I'm trying to create a RouterGuard in Angular that gets a response from the backend about the User's login status. The problem is that the HTTP request returns a Subscription with async concrete ...
0
votes
1
answer
89
views
execute a sequence of GET calls to an API wait and do some treatments on the results then give the result as argumant to another methode for a POST
I am new to Angular and i am facing some difficulties with a task. I have an array of IDs that i want to execute the same GET Call over. And for every GET call result i have to do some operations and ...
0
votes
2
answers
322
views
Cannot read properties of undefined (reading 'get') at get xyzArray [as xyzArray] Angular 14
I'm trying to implement FormArray into my project to generate dynamic FormControls.But I'm stuck at this error which I'm not able to understand.Whenever I create a getter method to get my array from ...
0
votes
3
answers
84
views
How to call Promise inside Promise and call function 2 times at a time in javascript
My code scenario is like :-
async function ot(a: any) {
return "outer text " + a;
}
async function it() {
return "inner text";
}
function insert() {
it().then(res =&...
0
votes
0
answers
13
views
Why does $q.when() promise chaining not work inside a while loop? [duplicate]
I was trying to chain a bunch of API calls based on a specific max count, until the offset specified for the API call does not exceed the max count. The offset is intended to increase by a constant ...
2
votes
1
answer
767
views
How to handle .toPromise() deprecation with RXJS and Angular 13
Hello I'm trying to figure out how to handle this deprecation on this code
const authCtx = (auth: AngularFireAuth) =>
setContext(async () => {
const token = await auth.idToken.pipe(take(1))...
0
votes
0
answers
21
views
Custom Service not giving desired result in controller in AngularJS 1.8
I have to debug a snippet written in AngularJS.
//===== service ==
app.service('allUserService', function($http) {
var config = {
headers: {
'X-XSRF-TOKEN': ...
0
votes
1
answer
547
views
Angular - Getting JSON data from HttpClient in a service not working properly
I'm trying to get JSON data in Angular using a service and I'm getting data with HttpClient using the get() method.
The problem is I'm using Promise and the function is returning a promise with the ...
0
votes
0
answers
28
views
Revert window.Promise back to native [duplicate]
I have a JS library (lets call it library 'a') which is an angular app component and is served through a CDN.
I also have another library (let call it library 'b') which was written in typescript and ...
0
votes
0
answers
20
views
Angular JS Promise Chaining
I have 2 functions that needs to be sequentially called one after another.Currently the secondFunc is called before the firstFunc completes execution .Any help as to what is wrong in this code would ...
0
votes
1
answer
213
views
How to read data from array after promise/observable call
I am not into javascript and angular, currently working on some UI task and has workable/little knowledge of javascript
what i want, base on a key field filter out the objects.
currently what code is ...
0
votes
0
answers
73
views
Uncaught (in promise): TypeError: Cannot read properties of undefined (rearsion') TypeError: Cannot read properties of undefined (reading version)
Who can help me this problem.
enter image description here
0
votes
1
answer
136
views
http call inside ngFor best practice
I have two models;
export interface Student {
id: string,
name: string
}
export interface StudentGoal{
id: string,
studentId: string,
goal: string
}
I get the students in my ...
0
votes
1
answer
146
views
Invoke async Method in Angular Typescript
We are new to angular and we are having few methods needs to be invoked in sequence and return a value. Here the return is invoking before completing the execution. I have tried different things like ...
1
vote
1
answer
654
views
Still use Promises in Angular? Is Angular Observable focused?
I was looking for a best practice in Angular whether to use Observables or Promises.
All the docs seem to use Observables, even on Angular Conferences they are just teaching that way. But most of the ...
1
vote
0
answers
483
views
Angular problem material mat-tabs does not show scroll arrows
I am loading some mat-tabs dynamically via a promise, but the mat-tab does not show the arrows to move when necessary.
but when clicking on a tap if they already show correctly
My code looks like ...
-1
votes
1
answer
174
views
Fetching results(location Data) from leaflet Geocoder through callback function
I am working on an angular project that uses leaflet framework for implementing geocoder. My current requirement is to use geocoder, retrieve the lat,lng from the results and emit them to the parent ...
0
votes
2
answers
3k
views
Uncaught (in promise): Error: 3000ms timeout exceeded Error: 3000ms timeout exceeded
I'm super new with promises, I'm trying to implement them but I have this error
Uncaught (in promise): Error: 3000ms timeout exceeded Error: 3000ms timeout exceeded
I'm also getting problem using ...
0
votes
1
answer
22
views
the button does not coming back into original state when subcribe completed
I am passing from parent an object array which includes a button inside, in this button I have 2 properties, enable and disable the button, and one more to execute a function, the button works fine, ...
0
votes
0
answers
142
views
D3.js how to merge my real data into a pie chart
I am new to D3 and data visualizing and I'm having some troubles loading my real data.
You'll find my code in the below sections.
Right now I have some data stored in an array, and now what I want to ...
0
votes
2
answers
1k
views
How to wait for code inside subscribe to finish before going to next iteration in forEach loop in Angular
In the below code, I have a for loop inside that one API is getting called. I want the 1st API call to be finished and code inside subscribe fully executes first and then the next iteration of for ...
0
votes
2
answers
878
views
Angular 10 method that returns value from REST API
Summary of Issue : Angular method does not wait till response is received from REST call before RETURNING the value
Description of Problem:
I have an endpoint that once consumed returns a date from ...
0
votes
1
answer
102
views
Angular 9 async-await Uncaught (in promise) Error
//to check the uploaded pdf file total pages > 5
static validatePdfFile(event: any) {
const file = event.target.files[0];
file.arrayBuffer().then(async buff => {
let ...
0
votes
1
answer
175
views
Calling function from HTML to typescript not waited to finish
I have an HTML element as bellow
<div *ngFor="let item of items">
<input type='number' [min]="getMinData(param1,param2)" />
</div>
inside ts file
getMinData(...
0
votes
1
answer
249
views
How to use a promise in a component to show an alert in the view
I have an Angular component that have a method that's being called when a form is submitted. And its calling a service method which returns a promise and im trying to use that to trigger an alert like ...
0
votes
1
answer
24
views
$q.all() - responses returned not in sequence
I have an array of promises in the following order:
promises = [promise1, promise2, promise3, promise 4, promise5];
Each promise is a http call..
I tried to retrieve the responses by so:
$q.all(...
1
vote
1
answer
889
views
Angular - sequential execute code after for loop
Please let me know if I have to provide any more code or explanations.
I am trying to execute some code after I call a service method inside a for loop. I tried two different ways.
In 1st method, the ...
0
votes
1
answer
511
views
How to capture angular JavaScript errors using event listener
We want to capture these two errors using JavaScript
ERROR TypeError: Cannot read property 'big' of undefined
at t.brokenCode (main.6e3ef82a1a9a4d77938a.js:1)
at main.6e3ef82a1a9a4d77938a.js:1
at Uo (...
0
votes
1
answer
412
views
Return observable bit first get new token in Angular 11 / RxJS 7
I'm having a really rough time with Angular / RxJS trying to learn it under crazy pressure!
If I'm returning this Observable:
return this.apiProvider.Tracker(parameters).map((res: any) => {
...
0
votes
2
answers
102
views
best way to run two or more asynchronous operations in a row inside a for loop
I have the following method that loops through a list of objects and for each node you need to execute a promise. What is the best way to execute two or more asynchronous operations in a row within a ...
2
votes
1
answer
3k
views
Angular api call: Observable vs Promise
I have this service that calls to an API to get a bunch of movie descriptions and returns an Observable:
getNowPlayingMovies$(page: number, country?: string): Observable<NowPlaying> {
...
0
votes
2
answers
52
views
Promise request after finishing one by one
I've used Promise.all() to get every request.
But I have got an error message from the server that I requested too many calls in a short period because the number of array I requested is over 100.
How ...
3
votes
2
answers
943
views
Angular promise with a async/await failure
So far, the suggestions I've seen to remedy my issue don't seem to apply, or I have a big misunderstanding (I haven't touched full stack in quite a while). I've got a service that successfully hits a ...
0
votes
1
answer
296
views
Array of ZoneAwarePromise during downloading elements from Azure in Angular
I am downloading files from Azure Blob storage via endpoint. For now I am waiting and downloading one by one in following part of my code.
for (let idx = 0; idx < blobArray.length ; idx++)
{
...
-1
votes
2
answers
542
views
'Promise<any>' is not assignable to type 'Contact[]'
I am already tried everything there on internet,and on stackoverflow I couldn't find the right answer. this is my first project in angular along with mongodb. But i am getting this error "Type '...
1
vote
1
answer
189
views
Async wait is not working when calling a function
var value = await this.upload();
if (value == true) {
this.item.photos = this.uploaded;
this.item.price = null;
this.item.qty = null;
this.dataSrv.addItem(this.item)
.then(() => {
...
0
votes
2
answers
217
views
Angular Promise don't work : ERROR TypeError: DataSource is undefined
i have issue by waiting dataSource is populated:
HTML
<app-single-y-axis [xAxysDataSource]="dataSource['labels']"
[yAxysDataSource]="dataSource['series']">
...
0
votes
2
answers
403
views
How exactly works this async-await method call? is it correct?
I am not so into Angular and async programming and I have the following doub.
Into a service class I have this async method:
async aestheticEvaluationExist(patientUID: string) {
console.log(&...
1
vote
1
answer
1k
views
BehaviorSubject subscription not listening for value changes
I am creating an angular app where I have an API service. This service calls API using axios and updates the value of BehaviorSubject as requires here is the code for that.
import { Injectable } from ...
0
votes
0
answers
83
views
Control the order of nested if-else via promise or async await
I have been struggling with a nested if-else which I would like to run all the conditions without returning, here's my code :
openMainModal: boolean;
openSecondaryModal: boolean;
mainFunction(isOpen ...
0
votes
1
answer
120
views
Cancel Request in AngularJS
I gone through some links:
How to cancel an $http request in AngularJS?
Cancelling ongoing Angular $http requests when there's a new request
How to cancel a $http call from controller in Angular ...
0
votes
2
answers
48
views
How exactly works this Promise.all() statement in my code?
I am pretty new in JavaScript technoogies and RxJS and I have the following doubt about how exactly works this code. It is taken from a project on which I am working and it works fine but I need to ...
0
votes
1
answer
176
views
Promise call gets invoked twice in Angular 11
I have below code which invokes a service to get some values, I knowingly shut down the backend part to check if error is being added. I noticed it makes the service call twice, can someone explain me ...
0
votes
0
answers
28
views
How to implement Async or Promise inside angular app (with heavy computations) [duplicate]
I have an Angular app which has only one TS file and one html View.
I was given a synchronous function CreateData(int categoryCount, int SubCategoryCount) that has couple of for loops in it which will ...
1
vote
1
answer
187
views
Why I can't use the Router object inside a function definied for the then() of a CRUD delete operation into my Angular service?
I am working on an Angular project and I have the following problem\doubt trying to use a Router class to navigate to a specifc page from the inside of a service class. I will try to explain my ...
0
votes
1
answer
476
views
Async await not working with image.onload
I have below async function in Angular 9. I am not very clear with Async await. Problem is op is assigned undefined as dataURI is not evaluated yet. Obviously I am using await async wrong. Pls help
...
1
vote
0
answers
285
views
in Angular 8.x is there a way to catch progress event of http requests using .toPromise() instead of .subscribe()?
Is there a way to catch the progress of the uploading/downloading of http request after .toPromise()ing the request?
The Documentation of Angular shows how to use reportProgress: boolean = true and ...
0
votes
1
answer
760
views
How correctly return a Promise from this Angular service method calling an external API?
I am working on an Angular application and I am finding the following problem. I have this service method:
// MANUALLY VERIFY\UNVERIFY EMAIL ADDRESS FOR USER REGISTRATION:
...