javascript - how to change textbox value from ng repeat -
i make own autocomplete in html
, use ng-repeat
show suggestion. code:
<div content-for="title"> <span>add friend</span> </div> <div class="scrollable"> <div class="scrollable-content"> <div class="list-group"> <div class="list-group-item"> <form class="form-inline" role="form"> <div class="form-group"> <label class="sr-only" for="exampleinputemail2">email</label> <input type="text" class="form-control" data-ng-model="add.email" id="exampleinputemail2" placeholder="email" auto-complete autocomplete="off"/> <div href="#" ng-repeat="x in cobas | filter:add.email"> <div class="media-body" ng-if="add.email.length > 0"> <h5 class="list-group-item media">{{x.name}} </div></div> </div> <button type="submit" class="btn btn-default" data-ng-click="addfriends()">add</button> </form> </div> </div> </div> </div>
what want is, when click suggestion result, value of textbox
change suggestion result using ng-click
, can me?
you have add function in controller, below:
$scope.autocomplete = function (completetext) { $scope.add.email = completetext; };
and in html call function on ng-click below,
<div href="#" ng-repeat="x in cobas | filter:add.email" ng-click="autocomplete(x.name)"> <div class="media-body" ng-if="add.email.length > 0"> <h5 class="list-group-item media">{{x.name}}</h5 </div> </div>
Comments
Post a Comment