angularjs - How to trigger the enter event for typeahead -


how trigger event in typeahead. have code below using typeahead , when user selects username in drop-down box of typeahead want fill user.full_name in text box below. have suggestion event should in use in typeahead input. suggestion

<div class="row">           <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">             <div class="form-group has-feedback" ng-class="showerror(userform.username)">               <label class="col-sm-4 control-label">{{'user.username' | translate}}:</label>               <div class="col-sm-8">                 <input type="text" name="username"                  ng-model="user.username" required ng-init="settimeout($element.focus(), 500)"                  typeahead="user user.username user in users | filter:$viewvalue | limitto:8"                 typeahead-on-select="select($model)"                 class="form-control">                 <span ng-show="showerror(userform.username)" class="glyphicon glyphicon-remove form-control-feedback"></span>               </div>             </div>           </div>         </div>         <div class="row">           <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">             <div class="form-group has-feedback" ng-class="showerror(userform.full_name)">               <label class="col-sm-4 control-label">{{'user.fullname' | translate}}:</label>               <div class="col-sm-8">                 <input type="text" class="form-control" name="full_name" ng-model="user.full_name">                 <span ng-show="showerror(userform.full_name)" class="glyphicon glyphicon-remove form-control-feedback"></span>               </div>             </div>           </div>         </div> 

below part of controller

.controller('adminuserscontroller', ['$rootscope', '$scope', '$state', '$stateparams', '$modal', '$log', '$timeout', 'usersapi', 'policiesapi','workspacesapi', 'msg', '$filter',   function($rootscope, $scope, $state, $stateparams, $modal, $log, $timeout, usersapi, policiesapi, workspacesapi,msg, $filter) {     var self = this,       limit = 100, ....   $scope.select = function (item) {       console.log('********* select ');       $scope.user.full_name = item.full_name;       console.log('foo', item);     };     // initialize page     self.refresh(); ... 

assuming you're using angularstrap typeahead,
trigger user input have :

$scope.$on('$typeahead.select', function(event, value, index, elem){      $scope.user.full_name = value; }); 

Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -