小编Tdi*_*ges的帖子

尝试在 appSettings.json 中设置环境变量 - Angular 和 Typescript

我基本上尝试在 appSettings 中设置 API URL 路径,以便我可以轻松地在生产和开发环境中来回更改。

这是我的 appSettings.json 文件。apiURL 是我试图设置和获取的变量。

{
 "Logging": {
"LogLevel": {
  "Default": "Information",
  "Microsoft": "Warning",
  "Microsoft.Hosting.Lifetime": "Information"
}
  },
 "AllowedHosts": "*",
 "apiURL": "http://10.241.2.68:8132/api"
}
Run Code Online (Sandbox Code Playgroud)

这是我的页面,它尝试访问我在 appSettings.json 中设置的环境变量。

import { Injectable } from '@angular/core';
// import { Defendant } from 'src/app/Models/Defendant';
import { Charge } from 'src/app/Models/Charge';
import { DefendantItem } from '../Models/DefendantItem';
import { Defendant_Charge } from '../Models/Defendant_Charge';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { AppConfiguration } from "read-appsettings-json"; …
Run Code Online (Sandbox Code Playgroud)

typescript angularjs-directive angular

3
推荐指数
1
解决办法
7710
查看次数

标签 统计

angular ×1

angularjs-directive ×1

typescript ×1