Pretty_Girl
Pretty_Girl

Reputation: 327

How to assign value to class properties?

I'm trying to set values of email and password variables to userreg which is in the type of UserRegister which should take email and password arguments.

Errors: Type 'string' is not assignable to type 'UserRegister'., Cannot redeclare block-scoped variable 'password'.

export class UserRegister {
    email: string = '';
    password: string = '';
    }

let email = '[email protected]';
let password = 'testpass';
let userreg: UserRegister = email, password; 


private doRegister(): void {
    this.Authentication.register(userreg)
    .catch((message: string) => this.formError = message);
        }

Upvotes: 2

Views: 745

Answers (1)

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

Your value assignation should be

const uEmail = '[email protected]';
const uPassword = 'testpass';
const userreg: UserRegister = {email: uEmail, password: uPassword };

Upvotes: 2

Related Questions