I have a model named User and I have an Observer in my service called getUsers which get a bunch of JSON objects in.
In my component I have the following
@Input() users: User[] = [];
and I and trying to use it like this:
getUserByLastName(lastName){
this._searchService.getUsers()
.filter(users => {
for(let user of users) {
if(user.lastName == lastName){
this.users.push(user);
}}})
.subscribe(users => this.users = users,
error =>this.errorMessage =<any> error);
return this.users;
}
However this line .filter(users => { is giving me an error saying:
Argument of type '(users: User[]) => void' is not assignable to
parameter of type '(value: User[], index: number) => boolean'. Type
'void' is not assignable to type 'boolean
I later try to use this to initialize the variable so I can populate it on a different form.
case "lastName":
this.users = this.getUserByLastName(this.lastName);
If that is confusing, I have two pages. One is hidden until a row is click in the default page. A form is in the other one (the hidden one) which populates data for the user (row) selected in a form to edit.