我有下面的類使用一個模型:無法在組件模板
export class Constants {
public static cREQUESTED_SERVICE: string = "RequestedService";
}
,我有以下模板組件(Service.component.html)(Service.component.ts):
<label>{{Constants.cREQUESTED_SERVICE}}</label>
我已經導入(常量)類裏面(Service.component.html)。問題是:標籤顯示爲空,並記錄在控制檯以下錯誤:
Subscriber.js:240遺漏的類型錯誤:當以往任何時候都使用的是無法讀取的不確定
我不想類添加爲供應商 – Ala
另一getter方法,但是這是做的方式。因爲你不應該有多個實例 – Aravind
@Aravind你不能訪問類實例的靜態屬性 –