Angular set value in radio button

Asked

Viewed 2,708 times

0

I have a field on the form with radio Buttons:

<div class="form-group" >
     <label class="control-label col-md-4">Tipo Atividade2*:</label>
     <input type="radio" [(ngModel)]="atividadeFixa" value="true" required> Fixa<br>
     <input type="radio" [(ngModel)]="atividadeFixa" value="false" required> Não Fixa<br>
</div>

I need to Load the value who comes from the back to the front. How can I do this ?

object code:

export class Atividade {

    atividadeFixa: boolean
}

code service

editarAtividade(atividade : Atividade) : Observable<any>{
        //return Observable.of("Edition not implemented yet")
        let params = this.setParamsAtividade(atividade)
        params.set("atividade", atividade.id.toString())
return this.http.doPut(Rotas.ATIVIDADE, params)
}
  • Which version of the angular vc is using?

  • I’m using the version of angular 6.0

  • Make a string Interpolation n resolve? value="{{valor}}"

  • 1

    [checked] = activity.activity ??

  • You want to checar the Rado button according to what comes from the back? If it is, how comes this back value?

  • that’s right. Doubt is at the value that comes from the back

  • And how comes that value?

  • the value type Boolean

Show 3 more comments

1 answer

1

How you are using ngModel only change the property value atividadeFixa.

I did in stackblitz an example with setTimeout() and changing the value of it kind of simulates a request.

Stackblitz example

  • Felipe Carlos is welcome...

  • How do I turn your segment into an angle function ?

  • just vc create a method and change the ngModel value in it

Browser other questions tagged

You are not signed in. Login or sign up in order to post.