Is there any impediment when binding template with get / set methods?


#1

I am a beginner in Ionic/Angular and would like to know if there is any problem or contraindication of using gets / sets methods in the ngModel directive?

Something like that:

@Component({
  selector: 'page-login',
  templateUrl: 'login.html',
})
export class LoginPage {

    private _username : string;

    private _password : string;

    //etc etc

    public get username(): string {
        return this._username;
    }

    public set username(value: string) {
        this._username= value;
    }


    public get password(): string {
        return this._password;
    }

    public set password(value: string) {
        this._password = value;
    }
}

Then, in my template:

<ion-input [(ngModel)]="username" name="username" type="text" required>
</ion-input>

<ion-input [(ngModel)]="password" name="password" type="password" required>
</ion-input>

Does this format normally work as if I were using the field directly?

Is there any limitation, some functionality that is not possible when we use get / set?

Is there any significant impact on performance?