2,117 questions
1
vote
0
answers
41
views
Resolve promise in a typescript non async function [duplicate]
I have a typescript file with the following non async function.
export function MSALInstanceFactory(): IPublicClientApplication {
const environmentService = new EnvironmentService();
const ...
0
votes
0
answers
60
views
Angular: Loading Indicator Stuck When Using Promises in Parent-Child Component
I am working on an Angular app (version 17). I have a parent component with two child components. On my page, I want to ensure that the content won't be displayed until all the data (from both the ...
1
vote
1
answer
113
views
Promise.all() never resolving
I have a function which should get some data asynchronously.
getPageEvents() {
const promises = this.calendarPage.days.map(day => {
return this.dataService.getEventsByDay(day)
....
1
vote
0
answers
115
views
Alternative to toPromise with downgradeInjectable
A service I've written in Angular is being consumed in a third party angularJS application. My pattern has been: create a service method which returns Observable<someType> and then create a ...
3
votes
2
answers
12k
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 file ...
0
votes
1
answer
353
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
3
answers
271
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 =&...
2
votes
1
answer
3k
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
31
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
1
answer
318
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 ...
2
votes
1
answer
2k
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
votes
1
answer
630
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
1
answer
31
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
2
answers
2k
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
1
answer
143
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
391
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 ...
1
vote
1
answer
2k
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
495
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) => {
...
3
votes
1
answer
5k
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> {
...
3
votes
2
answers
2k
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 ...
-1
votes
2
answers
765
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 '...
0
votes
2
answers
366
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']">
...
1
vote
1
answer
2k
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
1
answer
203
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
1
answer
379
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 ...