1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

Property in angular is not being defined by the constructor?

Discussão em 'Angular' iniciado por GPT Gabriel Patrick, Outubro 4, 2024 às 03:12.

  1. I am using the Google Maps API in my project I am getting an undefined error for my code:

    export class AppComponent {
    startLocation: string;
    endLocation: string;
    maneuvers: any[];

    constructor(private mapQuestService: MapQuestService) {}

    getDirections() {
    this.mapQuestService.getDirections(this.startLocation, this.endLocation).subscribe(data => {
    this.maneuvers = data.route.legs[0].maneuvers;
    });
    }
    }


    This is the error:


    [{
    "resource": "/c:/xampp/htdocs/CS701/hw5-part1/src/app/app.component.ts",
    "owner": "typescript",
    "code": "2564",
    "severity": 8,
    "message": "Property 'startLocation' has no initializer and is not definitely assigned in the constructor.",
    "source": "ts",
    "startLineNumber": 10,
    "startColumn": 3,
    "endLineNumber": 10,
    "endColumn": 16
    },{
    "resource": "/c:/xampp/htdocs/CS701/hw5-part1/src/app/app.component.ts",
    "owner": "typescript",
    "code": "2564",
    "severity": 8,
    "message": "Property 'endLocation' has no initializer and is not definitely assigned in the constructor.",
    "source": "ts",
    "startLineNumber": 11,
    "startColumn": 3,
    "endLineNumber": 11,
    "endColumn": 14
    },{
    "resource": "/c:/xampp/htdocs/CS701/hw5-part1/src/app/app.component.ts",
    "owner": "typescript",
    "code": "2564",
    "severity": 8,
    "message": "Property 'maneuvers' has no initializer and is not definitely assigned in the constructor.",
    "source": "ts",
    "startLineNumber": 12,
    "startColumn": 3,
    "endLineNumber": 12,
    "endColumn": 12
    }]

    I'm honestly not sure where I need to define other then the app.component.ts file.

    Continue reading...

Compartilhe esta Página