title: Get object data to variable in Angular
body: <p>Currently I'm doing a project in Angular with several JSON files. I have an anchor in my main component with routerLinks. I pass an angular bind to router path as variable by routerLink in module.ts and take that variable to another component called Filter. After getting variable in Filter component, I'm creating an url to get JSON data. I append the variable to url to complete the url, so that I can call different JSON files. </p>
  
  <p>The problem is, the incoming variable called sub.name in Filter component, shows in the console correctly as {"sub.name":"ABC"} but when I put it into a variable, It shows as [object Object]. I used JSON.stringify() to convert it to a variable but still the problem arise. </p>
  
  <p>This is what I have:</p>
  
  <p>category.component.html</p>
  
  <pre><code>&lt;ng-template #s&gt;&lt;dd&gt;&lt;a routerLink="{{sub.name}}" routerLinkActive="active"&gt;{{sub.name}}&lt;/a&gt;&lt;/dd&gt;&lt;/ng-template&gt;
  </code></pre>
  
  <p>app.module.ts</p>
  
  <pre><code>const appRoutes: Routes = [
    { path: 'explore-all-item', component: AllItemsComponent },
    { path: ':sub.name', component: FilterComponent }
      ];
  </code></pre>
  
  <p>filter.component.ts</p>
  
  <pre><code>import { Component, OnInit, Input } from '@angular/core';
  import { HttpClient} from '@angular/common/http';
  import {ActivatedRoute} from "@angular/router";
  
  @Component({
    selector: 'app-filter',
    templateUrl: './filter.component.html',
    styleUrls: ['./filter.component.css']
  })
  export class FilterComponent {
  
      cat:string;
      temp:string;
  
      @Input() url:string;
  
    constructor(private httpClient:HttpClient, private route: ActivatedRoute) {
  
      this.route.params.subscribe((params:any) =&gt; {this.temp = params})
  
      this.httpClient.get('http://myapp/explore/'+this.temp)
  
      .subscribe(
              (dat:any) =&gt; {
  
                  this.cat = JSON.stringify(dat[0]);
              }
          )
    }
  }
  </code></pre>
  
  <p>filter.component.html</p>
  
  <pre><code>&lt;div&gt;
      &lt;p&gt;{{temp}} is url&lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And the output is [object Object] is url.
  How I overcome this?</p>