angularjs - using angular-ui bootstrap typeahead how do i fetch values from json to feed in to two different input tags -
angularjs - using angular-ui bootstrap typeahead how do i fetch values from json to feed in to two different input tags -
i have done autocomplete json file in input tag, json file has multiple attributes, want separate input carry different attribute json file, eg: 1 1 input should fetch "driver_name" , other should fetch "vehicle_number", sec input tag needs filled automatically, 1 time select info first input tag
[ { "id": 1, "driver_name": "rohit", "driver_phone": "9176649143", "vehicle_type": "indica", "vehicle_number": "tn 06 ar 4556" }, { "id": 2, "driver_name": "john", "driver_phone": "9176648143", "vehicle_type": "fiat", "vehicle_number": "ca 06 ar 4556" } ] html
<div ng-controller="typeaheadctrl"> <div class="input-group m-bot15"> <input ng-model="tripsheet.vehicle_no" type="text" class="form-control input-lg" placeholder="vehicle no" typeahead="unidade.vehicle_number unidade.vehicle_number unidade in getunidades($viewvalue)"> </div> <div class="input-group m-bot15"> <input ng-model="tripsheet.driver_name" type="text" class="form-control input-lg" placeholder="vehicle no" typeahead="unidade.driver_name unidade.driver_name unidade in getunidades($viewvalue)"> </div> </div> js
function typeaheadctrl($scope, $http) { $scope.selected = undefined; $scope.getunidades = function($viewvalue) { homecoming $http.get(urldr + '/all').then(function(response){ homecoming response.data; }); }; }
should able add together filter typeahead function:
$scope.getunidades = function($viewvalue, filter) { homecoming $http.get(urldr + '/all').then(function(response){ var values = []; (var = 0; < response.data.length; i++) { if (response.data[i][filter].indexof($viewvalue) > -1) values.push(response.data[i]) } homecoming values; }); }; and filter property name filter on
json angularjs angular-ui-bootstrap
Comments
Post a Comment