Angular (4.x): Cannot use same name attribute for radio buttons -


i'm trying make radio buttons work, angular complains "name" attribute.

  <form>     <div>       <h3>select building</h3>       <h4>building search</h4>       <label for="criteria">search criteria:</label>        <input class="radio-input" type="radio" name="building-search-criteria" [(ngmodel)]="build_search_criteria" [value]="id" id="id">       <label class="radio-label" for="id">id</label>        <input class="radio-input" type="radio" name="building-search-criteria" [(ngmodel)]="build_search_criteria" [value]="name" id="name">       <label class="radio-label" for="nombre">name</label>    </div> </form> 

in order make radio buttons work, have share samenameattribute, seemingly angular doesn't that:

if ngmodel used within form tag, either name attribute must set or form       control must defined 'standalone' in ngmodeloptions.        example 1: <input [(ngmodel)]="person.firstname" name="first">       example 2: <input [(ngmodel)]="person.firstname" [ngmodeloptions]="{standalone: true}"> 

build_search_criteriais string variable. if understand, since bound model, value defined thevalueattribute of chosen radio button.

how can make radio buttons work? thank you.

use value instead of [value].as [value] expects variable.and yeah, not giving ngmodel related error me , should not.

<form>   <div>      <h3>select building</h3>      <h4>building search</h4>      <label >search criteria:</label>      <label class="radio-label" for="id">id</label>      <input class="radio-input" type="radio" name="building-search-criteria"         [(ngmodel)]="build_search_criteria"        value="id"        id="id">     <label class="radio-label" for="name">name</label>    <input class="radio-input" type="radio"   name="building-search-criteria" [(ngmodel)]="build_search_criteria"    value="name" id="name">  </div> </form> 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -