title: How to pass parameter in function call in angular 6?
body: <p>freeapiservice is my web service in which I want to call a function from
  another class <code>app.component</code>  in <code>insertFormadata</code> function I want to
  call a parameter from <code>app.component</code>:</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { Observable } from 'rxjs';
  import { HttpClient, HttpParams } from '@angular/common/http';
  
  @Injectable()
  export class freeApiService {
      constructor(private httpclient: HttpClient) {
      }
  
      insertFormadata(): Observable&lt;any&gt; {
          return this.httpclient.get("/api/api?type=savedata&amp;fname=nilesh&amp;tfvalue=js&amp;mobile=6547896541&amp;type_sec=1452&amp;city=bhopal&amp;email=nkardate@gmail.com")
      }
  
      getcomments(): Observable&lt;any&gt; {
          return this.httpclient.get("http://jsonplaceholder.typicode.com/posts/1/comments")
      }
  
      getcommentsbyparameters(): Observable&lt;any&gt; {
          let params1 = new HttpParams().set("userId", "1");
          return this.httpclient.get("http://jsonplaceholder.typicode.com/posts", { params: params1 })
      }
  }
  </code></pre>
  
  <p><code>app.component.ts</code> file code here <code>onSubmit</code> click I have <code>JSON.stringify(this.data.name)</code> this value i want to pass to the webservice api.</p>
  
  <pre><code>import { Component } from '@angular/core';
  import { freeApiService } from './services/freeapi.service';
  import { Comments } from './classes/comments';
  import { from } from 'rxjs';
  import { Posts } from './classes/posts';
  
  @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
  })
  export class AppComponent {
      title = 'applykaroo';
      data: any = {};
  
      onSubmit() {
          alert(JSON.stringify(this.data.name));
          this._freeApiService.insertFormadata().subscribe(
              data =&gt; {
                  this.lstcomments = data;
              }
          );
      }
  
      constructor(private _freeApiService: freeApiService) {
      }
  
      lstcomments: Comments[];
      lstparacomments: Posts[];
  
      ngOnInit() {
          this._freeApiService.getcomments().subscribe(
              data =&gt; {
                  this.lstcomments = data;
              }
          );
          this._freeApiService.getcommentsbyparameters().subscribe(
              data =&gt; {
                  this.lstparacomments = data;
              }
          )
      }
  }
  </code></pre>