AngularJS and Image Picker - I can not capture content from the picker

0

I have the following question:

If I click on the picker (in the box), I can capture the contents of the ng-model "first game" and manipulate it in javascript as needed:

<p>Escolha o jogo</p> 
<select class="image-picker show-html" ng-model="primeiroJogo">
    <option
      data-img-src='../public/images/logosmite.jpg'
      value="Smite"
      class="image-picker"
    ></option>
    <option
      data-img-src='../public/images/logohmm.jpg'
      value="Heavy Metal Machines"
      class="image-picker"
    ></option>
</select>

But what I need is to be able to capture the contents of this ng-model if the user clicks directly on the image. Would anyone know how to do this?

    
asked by anonymous 02.10.2018 / 21:20

1 answer

1

Is there any need to use select ?

You get the result you want by using input: radio

It would look something like this:

<p>Escolha o jogo</p>
<div class="image-picker show-html">
  <label>
    <input type="radio" ng-model="primeiroJogo" value="Smite">
    <img src="../public/images/logosmite.jpg" alt="">
  </label><br />
  <label>
    <input type="radio" ng-model="primeiroJogo" value="Heavy Metal Machines">
    <img src="../public/images/logohmm.jpg" alt="">
  </label>
</div>
    
29.10.2018 / 17:33