angularjs - Custom validation directive does not work -


i have input field typeahead in html form shown below

<input type="text" ng-model="selected" typeahead="state state in states | filter:$viewvalue | limitto:8"><br/> 

typeahead values loaded form js shown below

   $scope.states = ['alabama', 'alaska', 'arizona', 'arkansas', 'california', 'colorado', 'connecticut', 'delaware', 'florida', 'georgia', 'hawaii', 'idaho', 'illinois', 'indiana', 'iowa', 'kansas', 'kentucky', 'louisiana', 'maine', 'maryland', 'massachusetts', 'michigan', 'minnesota', 'mississippi'];  

this working expected. need validation check input value selected states lookup or not. appreciated.

see demo: http://plnkr.co/edit/qlfp6d5a9xj97tav5l66?p=preview

you can set typeahead-on-select property.

<input ... typeahead-on-select='onselect($model)'> 

and add callback function in controller:

$scope.onselect = function ($model) {     console.log("selected", $model); }; 

see demo


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -