Pick up complete array with Angularjs

Asked

Viewed 607 times

0

Template

<input type="text" data-ng-model="item.title" list="comicstitle">
  <datalist id="comicstitle">
    <option  data-ng-repeat="ttl in titles" value="{{ttl.name}}">
  </datalist>

js

$rootScope.titles = [{"id":"1","name":"Alface","value":"1.00"},{"id":"3","name":"Bacon","value":"2.00"},{"id":"4","name":"Queijo Cheedar","value":"2.00"},{"id":"5","name":"Mostarda Dijon","value":"2.00"}];

I need you to find the item input with the data of the array

<input type="text" ng-model="name">
<input type="text" ng-model="id">
<input type="text" ng-model="value">
  • 1

    Is this what you are looking for? http://jsfiddle.net/dieegov/g2oc1mmn/

  • Diego that really thank you

1 answer

1


Just do it this way

HTML

<div ng-controller="myCtrl">
    <input type="text" ng-model="item.title" list="comicstitle" />
    <select id="comicstitle" ng-model="item.titles">
        <option  value="{{$index}}" ng-repeat="ttl in titles"> {{ttl.name}} </option>
    </select>

    <input type="text" ng-model="titles[item.titles].name" />
    <input type="text" ng-model="titles[item.titles].id" />
    <input type="text" ng-model="titles[item.titles].value" />
</div>

Implement your solution.

JSFIDDLE DEMO

Browser other questions tagged

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