1
resposta

Como habilitar um RadioGroup somente se um determinado input tiver conteúdo?

Quero deixar de ínicio os radios desabilitados, e somente habilita-los se o campo celular for preenchido.

 <div class="accordion">Cadastro</div>
              <div class="card-body p-12">
                    <form class="col s12" [formGroup]="form" (ngSubmit)="save()">
                    <div class="row justify-content-between">
                        <div class="form-group col-sm-6 mr-auto">
                            <label for="licenciadoId">Licenciado</label>
                            <input ngui-auto-complete
                                    formControlName="licenciado"
                                    [source]="licenciadoObservable.bind(this)"
                                    [list-formatter]="licenciadoFormatter"
                                    value-property-name="licenciadoId"
                                    display-property-name="licenciadoRazaoSocial"
                                    class="form-control"
                                    #licenciadoElement>
                            <app-validation-message-for [displayMessage]="displayMessage" controlName="licenciado"></app-validation-message-for>
                        </div>
                        <div class="form-group col-sm-6 mr-auto">
                            <label for="licenciadoId">Usuário</label>
                            <input ngui-auto-complete
                                   [list-formatter]="usuarioFormatter"
                                   class="form-control"
                                   #usuarioElement>
                        </div>
                    </div>
                    <div class="row">
                      <div class="form-group col-sm-12">
                          <label for="analistaNome">Nome Completo</label>
                          <input type="text" id="analistaNome" class="form-control" formControlName="analistaNome" />
                          <app-validation-message-for [displayMessage]="displayMessage" controlName="analistaNome"></app-validation-message-for>
                      </div>
                    </div>
                    <div class="row">
                        <div class="form-group col-sm-6">
                            <label for="analistaTelefoneFixo">Telefone</label>
                            <input [textMask]="{mask: maskTel}" type="text" id="analistaTelefoneFixo" class="form-control" formControlName="analistaTelefoneFixo"/>
                            <app-validation-message-for [displayMessage]="displayMessage" controlName="analistaTelefoneFixo"></app-validation-message-for>
                        </div>
                        <div class="form-group col-sm-6">
                            <label for="analistaCelular">Celular</label>
                            <input [textMask]="{mask: maskCel}" type="text" id="analistaCelular" class="form-control" formControlName="analistaCelular" />
                            <app-validation-message-for [displayMessage]="displayMessage" controlName="analistaCelular"></app-validation-message-for>
                        </div>
                      </div>
                      <div class="row">
                        <div class="form-group col-sm-6">
                            <label for="analistaWhatsapp">Whatsapp</label>
                            <!--<input type="text" id="analistaWhatsapp" class="form-control" formControlName="analistaWhatsapp" />-->
                            <div class="btn-group">
                                <label for="radioAtivo" class="btn btn-light">
                                    <input class="form-control" type="radio" id="radioAtivo" formControlName="analistaWhatsapp" value="S" ng-disabled="form.$invalid" /> Sim
                                </label>
                                <label for="radioInativo" class="btn btn-light">
                                    <input class="form-control" type="radio" id="radioInativo" formControlName="analistaWhatsapp" value="N" ng-disabled="userForm.$invalid" /> Não
                                </label>
                            </div>
                            <app-validation-message-for [displayMessage]="displayMessage" controlName="analistaWhatsapp"></app-validation-message-for>
                        </div>
                        <div class="form-group col-sm-6">
                            <label for="analistaEmail">Email</label>
                            <input type="text" id="analistaEmail" class="form-control" formControlName="analistaEmail" />
                            <app-validation-message-for [displayMessage]="displayMessage" controlName="analistaEmail"></app-validation-message-for>
                        </div>
                      </div>
                  </form>
              </div>
1 resposta

Tente isso

<input class="form-control" type="radio" id="radioAtivo" formControlName="analistaWhatsapp" value="S" ng-disabled="{{form.get('analistaCelular').valid}}" /> Sim