Skip to content

Instantly share code, notes, and snippets.

@andrewarosario
Created February 7, 2023 21:16
Show Gist options
  • Save andrewarosario/c070535d6446a19bd3031030d9664097 to your computer and use it in GitHub Desktop.
Save andrewarosario/c070535d6446a19bd3031030d9664097 to your computer and use it in GitHub Desktop.
@Component({
selector: 'my-app',
template: `
<h1>Envie seu feedback</h1>
<form [formGroup]="form" (ngSubmit)="onSubmit()">
<div>
<label>
Sua avaliação:
<app-star-rating formControlName="rating"></app-star-rating>
</label>
</div>
<div>
<label>Quer informar um comentário?</label>
<input formControlName="comment" />
</div>
<button type="submit" [disabled]="form.invalid">Submit</button>
</form>
`,
})
export class AppComponent {
form = new FormGroup({
rating: new FormControl(
{ value: null, disabled: false },
Validators.required
),
comment: new FormControl(''),
});
onSubmit(): void {
console.log(this.form.value);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment