How to Read values from nested json objects in the config.json file with the help of config service class

This is my config.json File { "timeout":10000 "Status":{ "Error":{"message":"Runtime","continue":False} } } And below is the config service class export class ConfigService { private config: Object = null; constructor(private http: HttpClient) {} public getConfig(key:any){ return this.config[key]; } public loadConfig() { return this.http .get<Config>(‘../configuration/config.json’) .toPromise() .then(Configdata => { this.config = Configdata; console.log("error duration:",Configdata); }); } } First […]

By rissa
Published
Categorized as angular, config.json, nested-object Tagged , ,

How to read the values of nested objects from the Config file

This is my config.json File { "Status":{ "Error":{"message":"Runtime","continue":False} } } First I want to read the value "Error" and the the value "False" and assign them to two different variables. How can I read those two values Any help is appreciated. Thankyou. Source: Angular Questions

By rissa
Published
Categorized as angular, config.json, nested-object Tagged , ,

Angular unit test for the below two methods in the configuration application

I built an application for Angular runtime configuration. I referred to https://gist.github.com/fernandohu/122e88c3bcd210bbe41c608c36306db9. Can someone help me to write Angular unit tests using Jasmine and Karma for the below methods? public getConfig(key:any){ return this.config[key]; } public load(){ return this.http .get<Config>(‘../assets/config.json’) .toPromise() .then(data =>{ this.config = data; console.log("host",data.host) }) } Source: Angular Questions

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq