Hello there! I have a question about creating a class that implements an interface and utilizes data from a .get service to instantiate a new object. Here is an example of what I'm trying to achieve:
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 => {this.users = new UserClass(data), console.log(data)},
error => alert(error + ' Error Get')
);
}
}
In the above code snippet, you can see how the UserClass is implemented:
import { User } from '../interfaces/user';
import { Address } from "../interfaces/address";
export class UserClass implements User {
public id: number
public name: string
public password: string
...
...
}
And here is the interface definition for User:
import { Address } from "./address"
export interface User {
name: string;
password: string;
lastNameA: string;
...
...
}
However, when attempting to use this implementation in the pros-component.ts file, I encountered the following error message:
Supplied parameters do not match any signature of call target.
[default] Checking finished with 1 errors
This issue might be related to my service setup. Here's a look at the UserService:
import {Injectable} from '@angular/core';
import {Http, Headers} from '@angular/http';
...
...