how to download PDF from byteArray in angular 11?

Issue I have byte array and I want to download pdf without any library, for example file-saver. service.ts return this.http.get(`${this.invoiceUrl}/GenerateInvoice`, { responseType: "arraybuffer", observe: "response", params } ); component.ts file(byte) { var byteArray = new Uint8Array(byte); var a = window.document.createElement(‘a’);

Continue reading

Cors Issue in Angulaar 11 with HttpClient

Issue this is my service file code. getSearchValue() { let headers = new HttpHeaders({ ‘Accept’: ‘application/json’, ‘Access-Control-Allow-Origin’: ‘*’, ‘Access-Control-Allow-Headers’: ‘Content-Type’, ‘Access-Control-Allow-Methods’: ‘GET,POST,OPTIONS,DELETE,PUT’, ‘Authorization’: ‘Bearer Key[enter image description here][1]’, }); let options = { headers: headers }; return this.http.get(this.baseUrl, options) }

Continue reading

Cors Issue in Angulaar 11 with HttpClient

Issue this is my service file code. getSearchValue() { let headers = new HttpHeaders({ ‘Accept’: ‘application/json’, ‘Access-Control-Allow-Origin’: ‘*’, ‘Access-Control-Allow-Headers’: ‘Content-Type’, ‘Access-Control-Allow-Methods’: ‘GET,POST,OPTIONS,DELETE,PUT’, ‘Authorization’: ‘Bearer Key[enter image description here][1]’, }); let options = { headers: headers }; return this.http.get(this.baseUrl, options) }

Continue reading

How can I switch the openAll() or closeAll() (button) from Angular Material expansion panel?

Issue I want to switch between 2 buttons: OpenAll and CloseAll. Can I read a boolean of mat-accordion if it’s all opened or closed? <div class="row"> <mat-icon *ngIf="accordion.open()" (click)="accordion.openAll()">open_in_full</mat-icon> <mat-icon *ngIf="!accordion" (click)="accordion.closeAll()">close_fullscreen</mat-icon> </div> <div class="message-box row" *ngIf="notes.length; else noResult"> <mat-accordion

Continue reading

How to use multiple formgroup inside the form array

Issue <div formArrayName="partners" style="margin-top:15px;" *ngIf="partner"> <div *ngFor="let partner of partners().controls; let i = index" [formGroupName]="i"> <div class="partner-background"> <div class="row"> <div class="col col-12"> <h6 style="padding:5px;">Manage Partner <button id="remove" class="btn" style="float:right;" *ngIf="partners().length > 1 && i>0" (click)="removePartner(i)"><i class="fas fa-minus-circle"></i></button></h6> </div> <div class="col

Continue reading

Angular 11: Why can't the compiler find 'GeolocationPosition' during compiling? "Cannot find name 'GeolocationPosition'"

Issue Why does the angular compiler can’t find GeolocationPosition and GeolocationPositionError? VSC doesn’t give an error and only during compiling it gives me an error. Error: src/app/modules/shared/services/position.service.ts:10:46 – error TS2304: Cannot find name ‘GeolocationPosition’. 10 private positionSource = new ReplaySubject<GeolocationPosition>(1);

Continue reading

Merge two observables to get the value of two different Dto

Issue I have two observables, each one you get the value of a Dto: this.about.aboutHeInfo().subscribe((heInfo: HemDto) => { this.uiUtils.openDialogResizable({ hem: heInfo }, true, AboutComponent).subscribe(); }); this.about.aboutPeInfo().subscribe((peInfo: PeoDto) => { this.uiUtils.openDialogResizable({ peo: peInfo }, true, AboutComponent).subscribe(); }); The problem is that

Continue reading

Angular 11 CORS issue proxy port being incremented

Issue I’m witnessing something that I really don’t like and that I think is the root of my issue : Access to XMLHttpRequest at ‘https://localhost:5001/calls/api/Auth/register’ (redirected from ‘http://localhost:4200/calls/api/Auth/register’) from origin ‘http://localhost:4200’ has been blocked by CORS policy: Response to preflight

Continue reading

Return false instead of undefined

Issue On an Angular 11 / Typescript application I have: authorize(policy: Policy) : Observable<boolean> { switch(policy) { case Policy.Admin: return zip(this.authenticationService.isSignedIn(), this.user$).pipe( map(([isSignedIn, user]: [boolean, UserModel]) => isSignedIn && user?.claims?.some((claim: Claim) => claim.value === ‘Admin’)) ); user is of type

Continue reading

Angular Form dynamic field

Issue I am wondering how to make an angular form with a dynamic step. I have the following form (TS) : this.registerForm = new FormGroup({ role: new FormControl(”, [ Validators.required, ]), firstName: new FormControl(”, [ Validators.required, Validators.minLength(2), Validators.maxLength(20), ]), lastName:

Continue reading

getting error as Cannot read property 'key' of undefined angular

Issue I am getting error for my below code error TypeError: Cannot read property ‘key’ of undefined at EditorComponent.push.xD4D.EditorComponent.setFillColor (editor.component.ts:634) ts setFillColor(swatch: any): void { this.palettes.selected = swatch; this.props.fill = swatch.key; this.setFill(); if (!this.props.canvasImage) { console.log(‘say hi’) this.canvas.backgroundColor = this.props.canvasFill;

Continue reading

Failed to execute 'setAttribute' on 'Element': Angular 11

Issue I’m getting following error in my new Angular 11 app. Could not found any syntax errors. core.js:6156 ERROR DOMException: Failed to execute ‘setAttribute’ on ‘Element’: ‘ng-reflect-Dev Portal’ is not a valid attribute name. at EmulatedEncapsulationDomRenderer2.setAttribute (http://localhost:8080/admin/vendor.js:62217:16) at setNgReflectProperty (http://localhost:8080/admin/vendor.js:38053:26)

Continue reading

Where to initialise a FormGroup in Reactive forms?

Issue Using Angular 11 with Typescript 4 in Strict Mode I have: export class ContactComponent implements OnInit { form: FormGroup; constructor(private formBuilder: FormBuilder) { } ngOnInit() { this.form = this.formBuilder.group({ email: [”, [Validators.required, Validators.email]], name: [”, [Validators.required, Validators.maxLength(40)]], }); }

Continue reading

How to initialise an empty ComponentRef?

Issue Using Angular 11 and Typescript Strict mode I have: export class ModalService { renderer: Renderer2; component?: ComponentRef<any>; element: HTMLElement | null; modal: HTMLDivElement; constructor(private componentFactoryResolver: ComponentFactoryResolver, private application: ApplicationRef, private rendererFactory: RendererFactory2, private popupService: PopupService) { this.renderer = rendererFactory.createRenderer(null,

Continue reading

Angular 11 wait until subscribe finishes getting data

Issue I have a auth.service and data.service. auth.service getting data from data.service but it checks before data arrives. So it returns undefined. auth.service getting data like this; get isLoggedIn(): boolean { const user = JSON.parse(localStorage.getItem(‘user’)); const emailVerify = this.dataservice.userStatService(user.uid); console.warn(emailVerify)

Continue reading

Select items per page into Angular and send param to Spring

Issue I’m trying to implement Spring pagination with Angular. I tried this code: Search DTO: public class ClassCategoriesSearchParams { private String title; private String type; private LocalDateTime publishedAt; } Endpoint: @PostMapping("/find") public Page<ClassCategoriesFullDTO> search(@Valid ClassCategoriesSearchParams params, Pageable pageable) { Page<ClassCategoriesFullDTO>

Continue reading

when i use router.getCurrentNavigation() inside ngOnInit() it gives me type error but when i use it inside constructor it works fine, why?

Issue Starter – export class HeaderComponent implements OnInit { constructor(private route: ActivatedRoute, private router: Router) {} onClick() { const navigationExtras: NavigationExtras = { state: { transd: ‘TRANS001’, workQueue: false, services: 10, code: ‘003’, }, }; this.router.navigate([‘/auth’], navigationExtras); } } AuthComponent

Continue reading