angularjs - Select a value from typeahead shows Objec object -


i working on single page application , using angular-typeahead when write in textbox shows me suggestions when select suggestion values of textbox become object object instead of name

here html markup

<div class="bs-example" style="padding-bottom: 24px;" append-source>     <form class="form-inline" role="form">       <div class="form-group">         <label><i class="fa fa-globe"></i> state</label>         <input type="text" class="form-control" ng-model="selectedstate" ng-options="state.firstname state in states" placeholder="enter state" bs-typeahead>       </div>     </form>   </div> 

and here angularjs code

var app = angular.module('mgcrea.ngstrapdocs', ['nganimate', 'ngsanitize', 'mgcrea.ngstrap'])          .controller('typeaheaddemoctrl', function ($scope, $templatecache, $http) {              $scope.selectedstate = '';              $http.get('/api/servicesapi/getallclients')             .then(                 function (result) {                     //success                     $scope.states = result.data;                 },                 function () {                     //error                 });          }); 

see images here

enter image description here enter image description here

change ng-options="state.firstname state in states" ng-options="state state.firstname state in states"


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -