0

I have a input "firstname" where I type letters and it gives all the letter matches via filter. Then when I select wanted match which is a button, it should be changing the value inside input as selected.

This works IF input field is empty, but when lets say, i'm searching all the ppl named "jake" and I type "j"-letter inside input; then I choose jake from the list.

Input still shows only the "j"-letter.

One input field where search happen. Input value should be overridden when new value is selected from the list. How to do this?

html:

<input type="text" id="firstName" class="form-control" ng-model="firstName" required />

<div>
    <ul ng-repeat="event in events | letterSearch:firstName | unique: 'email'">
        <li>
            <button class="btn btn-sm" ng-click="fillForm(event.firstName)">{{event.firstName}} </button>                                 
        </li>
    </ul> 
</div>

js:

$scope.fillForm = function (firstN) {
    $scope.firstName = firstN;
};

Thx beforehand =)

LionC
  • 3,106
  • 1
  • 22
  • 31
edu
  • 53
  • 7
  • If you are new to Angular, I highly recommend not using `$scope` but to [use `controllerAs` syntax instead](http://stackoverflow.com/questions/32755929/what-is-the-advantage-of-controller-as-in-angular/32756679#32756679) – LionC Feb 16 '17 at 10:57
  • 1
    It's better if you put the complete code on jsfiddle or something :) – ngrj Feb 16 '17 at 10:59
  • @LionC THIS! Thank you =) – edu Feb 16 '17 at 11:40

0 Answers0