title: Angular 2: Create objects from a class
body: <p>Hello I'm wondering if it's possible to create a class where you implement an interface and from there you send the data get from .get service to create a new object. Something like this</p>
  
  <pre><code>import { Component, OnInit } from '@angular/core';
  import { User} from '../interfaces/user';
  import {UserService} from '../services/user.service';
  import { UserClass } from  '../classes/user-class'
  
  @Component({
    selector: 'up-pros',
    templateUrl: './pros.component.html',
    providers: [UserService]
  })
  export class ProsComponent implements OnInit {
    public users :User[];
    public term: string;
    constructor(private _httpService: UserService) { }
  
    ngOnInit() {
      console.log(UserClass)
      this.term= 'INSTRUCTOR';
      this._httpService.searchUsers(this.term)
          .subscribe(
            data =&gt; {this.users = new UserClass(data), console.log(data)},
            error =&gt; alert(error + ' Error Get')
          );
    }
  }
  </code></pre>
  
  <p>where my UserClass code is something like next one</p>
  
  <pre><code>import { User } from '../interfaces/user';
  import { Address } from "../interfaces/address";
  
  export class UserClass implements User {
  
  public  id:           number
  public  name:         string
  public  password:     string
  public  lastNameA:    string
  public  lastNameB:    string
  public  photo:        string
  public  telephone:    string
  public  email:        string
  public  userType:     string
  public  active:       string
  public  score:        number
  public  createdAt:    string
  public  updatedAt:    string
  public  Address:      Address
  
  constructor ( id:           number,
                password:     string,
                name:         string,
                lastNameA:    string,
                lastNameB:    string,
                photo:        string,
                telephone:    string,
                email:        string,
                userType:     string,
                active:       string,
                score:        number,
                createdAt:    string,
                updatedAt:    string,
                Address:      Address)  {
                  this.name       = name
                  this.password   = password
                  this.lastNameA  = lastNameA
                  this.lastNameB  = lastNameB
                  this.photo      = photo
                  this.telephone  = telephone
                  this.email      = email
                  this.userType   = userType
                  this.active     = active
                  this.score      = score
                  this.createdAt  = createdAt
                  this.updatedAt  = updatedAt
                  this.Address    = Address
                }
  
  }
  </code></pre>
  
  <p>and by the last, the interface:</p>
  
  <pre><code>import { Address } from "./address"
  
  export interface User {
    name:       string;
    password:   string;
    lastNameA:  string;
    lastNameB:  string;
    photo:      string;
    telephone:  string;
    email:      string;
    userType:   string;
    active:     string;
    score:      number;
    createdAt:  string;
    updatedAt:  string;
    Address:    Address;
  }
  </code></pre>
  
  <p>Is this possible? because if I try to do this Im getting the next error at pros-component.ts:</p>
  
  <pre><code>Supplied parameters do not match any signature of call target.
  [default] Checking finished with 1 errors
  </code></pre>
  
  <p>My service:</p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import {Http, Headers} from '@angular/http';
  import 'rxjs/add/operator/map';
  import { User } from '../interfaces/user';
  
  
  @Injectable()
  export class UserService {
    url= 'http://localhostapi/users';
  
    constructor(private _http: Http){}
  
  
    getUsers(){
      return this._http.get(this.url)
        .map(res =&gt; res.json());
    }
  
    searchUsers(term : string ){
      return this._http.get('http://localhostapi/listas?user='+term)
        .map(res =&gt; res.json());
  
    }
    searchUser(term : string ){
      return this._http.get('http://localhostapi/users/'+term)
        .map(res =&gt; res.json());
  
    }
  
    postUsers(user: User){
  
      var headers = new Headers ();
      headers.append('Content-Type','application/json');
      return this._http.post(this.url, user, {headers: headers})
      .map(res =&gt; res.json());
    }
  
    updateUsers(user: User, term: string){
  
      var headers = new Headers ();
      headers.append('Content-Type','application/json');
      return this._http.put(this.url+"/"+term, user, {headers: headers})
      .map(res =&gt; res.json());
    }
  }
  </code></pre>