[英]how to import the config ts file in ionic2 other ts file
而在其他ts文件(例如/pages/home/home.ts)中導入app.config.ts文件
我在app.config中使用了以下代碼
import { OpaqueToken } from "@angular/core";
export let APP_CONFIG = new OpaqueToken("app.config");
export interface IAppConfig {
apiEndpoint: string;
}
export const AppConfig: IAppConfig = {
apiEndpoint: "http://localhost:15422/api/"
};
請幫助我,以使用此app.config並在app.module中定義
在您的app.module.ts
,將其設置為provider:
{ provide: APP_CONFIG, useValue: AppConfig },
在上課時
constructor(@Inject(APP_CONFIG) private config: IAppConfig,..){}
您可以將值作為config.apiEndpoint
訪問
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.