# Set initial value to a Toggle of a form in Angular Material within HTML

I am working with a simple form:

HTML

<mat-card>
<mat-form-field>
<textarea #description="ngModel" matInput rows="6" placeholder="Description" name="description" ngModel
required></textarea>
<mat-error *ngIf="description.invalid">Please enter a Bet Description</mat-error>
</mat-form-field>
<mat-slide-toggle #privacy="ngModel" name="privacy" ngModel>Private</mat-slide-toggle>
<button mat-raised-button color="primary" type="submit">
CREATE
</button>
</form>
</mat-card>


If I press submit without touching any field of the form I get all the fields empty as it should be expected but I would like to get instead of the status of the form, meaning all the fields as "" but in the fields “privacy” and “comments” as false (boolean) (the default appearance of the toggles is as not marked).

I know that this could be easily done by Typescript from the component following the method:

Typescript

onAddBet(form: NgForm) {
if (!form.value.privacy) {
form.value.privacy = false;
console.log(form.value);
} else console.log(form.value);
if (form.invalid) return;
form.resetForm();
}


But I was wondering if there is any HTML attribute to run the same code avoiding to use Typescript

How could I do it?

Source: New feed
Source Url Set initial value to a Toggle of a form in Angular Material within HTML