Reputation: 373
In this part code --> expected 0-1 arguments but got 5. Can you suggest me any solution?
Register() {
let newUser = new User(this.registerForm.value,
newUser.city =this.cityid,
newUser.regionId = this.regionid,
newUser.country_id = this.countryid,
newUser.roleId = this.roleid,
);
this.ws.createUser(newUser).subscribe(
);
}
export class User {
password: string;
roleId: string;
firstName: string;
.
.
.
}
Thank you!
Upvotes: 0
Views: 3070
Reputation: 19194
Add a constructor setting the values to the class variables.
class User {
//declarations
constructor(value, city, regionId, countryId, roleid) {
this.value = value;
this.city = city;
this.regionId = regionId;
this.countryId = countryId;
this.roleId = roleId;
}
//...
}
You are providing 5 arguments to the constructor, so it needs to have 5 values there.
If you actually want to pass an object, then pass an object as argument:
let newUser = new User(this.registerForm.value);
//rest of the code
Upvotes: 2