我是 angular-cli 的新手,想通过 env 为我的 api 服务调用加载 url。例如
local: http://127.0.0.1:5000
dev: http://123.123.123.123:80
prod: https://123.123.123.123:443
例如在 environment.prod.ts
我假设:
export const environment = {
production: true
"API_URL": "prod: https://123.123.123.123:443"
};
但是从 angular2,我该如何调用才能获取 API_URL?
例如
this.http.post(API_URL + '/auth', body, { headers: contentHeaders })
.subscribe(
response => {
console.log(response.json().access_token);
localStorage.setItem('id_token', response.json().access_token);
this.router.navigate(['/dashboard']);
},
error => {
alert(error.text());
console.log(error.text());
}
);
}
谢谢