Questions tagged undefined

Explore the latest questions and answers asked by our top developers.

Table doesn’t get value because value is undefined

i’m trying do a bidding in my table with returned datas in angular. But props values is undefined. My Component: export class EquipmentsComponent implements OnInit { form: any; titleForm!: string; equipments!: Equipments[]; constructor(private EquipmentService: EquipmentsService) { } ngOnInit(): void { this.EquipmentService.Getall().subscribe(result => { this.equipments = result; }); } My service: const httpOptions = { headers: […]

Trustpilot: window.Trustpilot.loadFromElement is undefined (Safari)

I want to put 3 trustPilots in my Angular app. import { Component, Input, OnInit } from ‘@angular/core’; declare global { interface Window { Trustpilot: any; } } window.Trustpilot = window.Trustpilot || {}; @Component({ selector: ‘app-trustbox-normal’, templateUrl: ‘./trustbox-normal.component.html’, styleUrls: [‘./trustbox-normal.component.scss’] }) export class TrustboxNormalComponent implements OnInit { constructor() { } ngOnInit(): void { } ngAfterViewInit(){ […]

Angular this.router is undefined even declared in the constructor

As you can see in my angular project I am inyecting the router in the constructor as I have done in several projects that a did a few years ago and i have forget a lot of things, the point is that is not redirecting me to /home and this.router is undefined. import { Component, […]

(Reason: CORS header ‘Access-Control-Allow-Origin’ missing). also showing id undefined

this is service file import { Injectable } from ‘@angular/core’; import { HttpClient, HttpHeaders } from ‘@angular/common/http’; import { Observable } from ‘rxjs’; @Injectable({ providedIn: ‘root’ }) export class ItemServicesService { constructor(private http: HttpClient) { } baseurl: string = ‘’ viewFunction(id: string) { return this.http.get(this.baseurl + ‘items/’ + id) } } this is view-component.ts file […]

By Manu Sunny
Categorized as angular, cors, undefined Tagged , ,

Typescript Error "Cannot read property ‘nativeElement’ of undefined"?

I have tried solutions present on Stackoverflow but none of them is working for me. I am getting message":"Cannot read property ‘nativeElement’ of undefined" error from typescript file I am using Angular ngAfterViewInit lifecycle hook I have discovered I am getting error at line const firstOcc = this.editElem.nativeElement.querySelector<HTMLElement>(‘.highlighted’); Below is my code @ViewChild(‘term’,{ static: false […]

Angular variable undefined

I have a function that is passed from service to get ip value ip i put it in property variable but the value becomes undefined ? when I check in the console this.ipClient variable if it exists in scope but why when I output it becomes undefined? how do I get that value out so […]

By Rezaldy Abidin
Categorized as angular, service, undefined Tagged , ,

Typescript : Type is not assignable to type

I’m getting the below error for this TypeScript code : getTodoById(id: number): Todo { return this.todos .filter(todo => === id) .pop(); { " "Type ‘Todo | undefined’ is not assignable to type ‘Todo’.n Type ‘undefined’ is not assignable to type ‘Todo’.", Source: Angular Questions

By DarBen
Categorized as angular, types, typescript, undefined Tagged , , ,

Angular question (Cannot read property ‘genre’ of undefined)

I’m a newbie so don’t judge me too hard. I’m trying to build a simple app similar to a tour of heroes(official angular tutorial). I faced one problem I can’t resolve as I think due to my bad understanding of fundamental programming knowledge. Here’s what I have: ngOnInit(): void { this.getMovie(); this.getSimilarMovies(); } getMovie(): any […]

By gogi15
Categorized as angular, undefined Tagged ,

TypeError: ctx.product is undefined

Help ! I’m getting the following error from my Angular (material) application: TypeError: ctx.product is undefined my service:product.service.ts @Injectable({ providedIn: ‘root’ }) export class ProductService { baseUrl = ‘http://localhost:3000/products’; constructor( private http: HttpClient, private router: Router, private snackBar: MatSnackBar) { } // Headers private httpOptions = { headers: new HttpHeaders({ ‘Content-Type’: ‘application/json’ }) }; showMessage(msg: […]

By Marcelo Freitas
Categorized as angularjs, javascript, undefined Tagged , ,

Typescript object property ‘undefined’ while it is not

I’m farly new with Typescript and struggle with what seems to be a dumb issue: I retrieve an ‘agent’ object from a service. this.agentsController.getAgent(matricule).subscribe({ next: agent => { console.log(agent) console.log(agent.emailPro) }, error: (error: string) => { console.log(error) } }); According to the 1st console.log, it is well populated : { "agent": { "matricule": "000001", "nom": […]

By Thomas L
Categorized as angularjs, typescript, undefined Tagged , ,
1 5

Still Have Questions?

Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us