Eu implementei da seguinte maneira abaixo, alterando o texto da propriedade placeholder
do Html.
Há alguma forma de implementar essa lógica direto no template?
@Input() allowComments: boolean
placeholder = 'Insert your comment here'
disabled: boolean = false
//codigo omitido
ngOnInit(): void {
if(!this.allowComments) {
this.placeholder = 'Commens disabled for this photo'
this.disabled = true
}
this.comments$ = this.photoService.getComments(this.photoId)
this.commentsForm = this.formBuilder.group({
commentText: [{value: '', disabled: this.disabled}, Validators.maxLength(300)]
})
//No template:
<textarea
[placeholder]="placeholder"
class="form-control"
formControlName = "commentText">
</textarea>
//inbound properties:
<ap-photo-comments [photoId]="photo.id" [allowComments]="photo.allowComments" ></ap-photo-comments>