importing a variable from one typescript file into another

Discussão em 'Angular' iniciado por user6781560, Dezembro 5, 2024.

  1. user6781560

    user6781560 Guest

    I am attempting to import a variable from one type script file into another.

    the variable I want to import is cityListUrl

    the type script file it is in is coded like this:

    export class backendUrls{

    // root url
    rooturl:string= 'http://127.0.0.1:8000';

    //get a list of all cities
    cityListUrl:string = this.rooturl + '/api/city/';


    }


    the file I want to import it into looks like this:

    import {Injectable} from '@angular/core';
    import {Http} from '@angular/http';
    import {backendUrls} from 'app/backendUrls';

    @Injectable()
    export class cityGetService{
    constructor(private http: Http){}

    cityGet(){
    this.http.get(backendUrls.cityListUrl)
    }
    }


    the cityListUrl in my pycharm editor is currently red. with the message

    TS2339: 'cityListUrl' does not exist on type 'typeof backendUrls'.


    has anyone had this issue before? How would I fix this? Thank you

    Continue reading...

Compartilhe esta Página