Created
February 7, 2023 21:16
-
-
Save andrewarosario/c070535d6446a19bd3031030d9664097 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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