title: How to read data from .json file in typescript
body: <p>I have a json file in assets folder called data.json</p>
  
  <pre><code>{
      "response": {
          "sales_amount": 0,
          "collection_amount": 0,
          "carts_amount": 736.63,
  
  }
  }
  </code></pre>
  
  <p>I am doing like this to get data in service.ts file</p>
  
  <pre><code> my_data: any;
    public getResponseData() : Promise&lt;any&gt; {
        if(typeof(this.my_data) === "undefined") {
              return this.http.get('assets/data.json')
              .toPromise().then(res =&gt; {
  
                                    this.my_data = res.json().response;
                                    return this.my_data;
                  }).catch(this.handleError);
        } else {
            return Promise.resolve(this.my_data);
        }
  
  
    }
  </code></pre>
  
  <p>Here i am getting response in this.my_data,but in the component.ts file i am doing like this</p>
  
  <pre><code>ngOnInit(){
  
  
          this.myService.getResponseData().then(response =&gt; this.detailsdata = response);
  }
  </code></pre>
  
  <p><strong>but here in this.detailsdata  i am not getting anything.</strong></p>
  
  <p>and after this i want to display <strong>sales_amount</strong>,<strong>collection_amount</strong> in the <strong>html</strong> file.</p>
  
  <pre><code>&lt;div&gt;
       &lt;span&gt;sales amount&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>In place of sales amount i want to display the value
  how to do this.
  I am very new to typescript.can anyone please help me with this.</p>