Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

typescript import variable from another file

//in the first file backendUrls.ts or js
export const rooturl = 'http://127.0.0.1:8000';
export const cityListUrl = rooturl + '/api/city/'
export const all = {
    rooturl, cityListUrl
}

//in the component
import {Injectable} from '@angular/core';
import {Http} from '@angular/http';
import {backendUrls} from 'app/backendUrls'; //import the file with variables here

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

  cityGet(){
    this.http.get(new backendUrls().cityListUrl) //use create new instance to use the variable
  }
}
Comment

PREVIOUS NEXT
Code Example
Typescript :: 3 dots react 
Typescript :: yup validation typescript 
Typescript :: if its past 24 hrs *laravel 
Typescript :: the html element that houses all html element that contains meta information about the web page,importing external stylesheets and internal ces 
Typescript :: endurance testing 
Typescript :: typescript enum value to enum 
Typescript :: multiple if statements in excel 
Typescript :: node scripts delay 
Typescript :: token authentication requirements for git operations 
Typescript :: typescript read url search params 
Typescript :: you can initiate objects from a 
Typescript :: typescript find in all words 
Cpp :: ue4 c++ print to screen 
Cpp :: Prime Number Checker 
Cpp :: best c++ pdf 
Cpp :: flutter datetime format 
Cpp :: how to print the address of an object in c++ 
Cpp :: std::string to qstring 
Cpp :: const iterator c++ 
Cpp :: map key exists c++ 
Cpp :: merge images opencv c++ 
Cpp :: erosion and dilation c++ 
Cpp :: what are specialized classes c++ 
Cpp :: unknown type name pid_t 
Cpp :: c++ remove last element from vector 
Cpp :: c++ find index of an element 
Cpp :: sort in descending order c++ stl 
Cpp :: c++ string to double 
Cpp :: quotation in c++ string 
Cpp :: c++ check if string contains non alphanumeric 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =