trying to read json file from my local project for some basic config.
code:
myM: any;
constructor(private http: Http) {
this.http.get('config.json')
.map((res: Response) => res.json())
.subscribe(res => {
this.parseHeaderJSON(res);
});
}
parseHeaderJSON(res) {
this.myM = res;
}
HTML:
<li><a href="{{myM.home_header.whatis.link_url}}" class="ripple-effect">{{myM.home_header.whatis.link_name}}</a></li>
but it always logs on console as undefined..
if I place console.dir(res) instead of value assign then it prints my object data but don't know why it does not assign to variable !!!
can anyone tell me where am I wrong ?
UPDATE
json file content:
{
"home_header":
{
"servicesweoffer":
{
"lable_name":"SERVICES WE OFFER",
"link_url":""
},
"pricing":
{
"lable_name":"PRICING",
"link_url":""
},
"contacutus":
{
"lable_name":"CONTACT US",
"link_url":""
}
}
}