I have some sensitive variables, and it would be ideal to leave all the variables in one environment, when it is necessary to change, for example from production to development, this task becomes easy.
Ex:
@Injectable()
export class RestaurantesProvider {
private url: string = "http://199.169.9.9/ws/ListarEstados.ashx";
constructor(private http: Http) {
console.log(this.url);
}
getRestaurantes(){
return this.http.post(this.url, null)
.do(this.logResponde)
.map(this.extractData)
.catch(this.catchError);
}
private catchError(error: Response | any){
console.log(error);
return Observable.throw(error.json().error || "Erro de conexção");
}
private logResponde(res: Response){
console.log(res);
}
private extractData(res: Response){
return res.json();
}
}
By default I would like to get the url
which in case it is a sensitive variable to use in all my requests, this service and the others.
private url: string = padrao + "ListarEstados.ashx";
I'm trying to use AppModule
for this done, so I did so:
export class AppModule {
private url: string = "http://199.169.0.9/ws/ListarEstados.ashx";
getUrl(){
return this.url;
}
}
And in my classe
I do so:
private url: string = AppModule.getUrl();
The getUrl()
is marked and this message appears
[ts] Property 'getUrl' does not exist on type 'typeof AppModule'