Here is the code for the AppComponent:
import { Component, OnInit } from '@angular/core';
import { APICommunicationService } from './api-comm/api-communication.service';
import { Observer } from 'rxjs';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
standalone: true
})
export class AppComponent implements OnInit {
vara = 'eksid';
responseData: any;
constructor(private apiCommunicationService: APICommunicationService) {}
ngOnInit(): void {
this.getDataFromAPI({
next: (data: any) => {
this.responseData = data;
// Process the received data as needed
},
error: (error: any) => {
console.error(error);
// Handle errors
},
complete: () => {
console.log('Request completed successfully');
// Additional actions after completion if needed
}
});
}
API_request_test(): void {
this.vara = this.responseData;
}
getDataFromAPI(observer: Observer<any>): void {
this.apiCommunicationService.getData().subscribe(observer);
}
}
And here is the code for the API connection service:
import { Injectable, NgModule } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { HttpClientModule } from '@angular/common/http';
@NgModule({
declarations: [],
imports: [HttpClientModule],
providers: [],
bootstrap: [/* ... */]
})
@Injectable({
providedIn: 'root'
})
export class APICommunicationService {
private apiUrl = 'https://localhost:7023/api';
constructor(private http: HttpClient) {}
getData(): Observable<any> {
return this.http.get<any>(`${this.apiUrl}/Test`);
}
}
I am facing an Angular issue that displays the following error message when I try to start the app:
record.factory is not a function
at eval (d:/Orch_front_ANGU/Orch_front/node_modules/@angular/core/fesm2022/core.mjs:6168:43)
...
The error occurs even when I remove the standalone attribute. Accessing "http://localhost:4200/" triggers this error. What could be causing this problem? Also, it's worth noting that I do not have "enableIvy" in my app configuration.