1. 程式人生 > >Typescript 靜態欄位(static)的宣告

Typescript 靜態欄位(static)的宣告

ts中定義靜態變數,加 public static, 和C#中類似。 

定義:

export class GlobalService {
  public static url: string = "http://localhost:4200/webapp";
}

引用:

import { GlobalService } from '../global.service';

//...

var url = GlobalService.url + "/device/all";