angularjs - how to prefill data with angucomplete plugin? -


i using angular angucomplete plugin. https://github.com/darylrowland/angucomplete

how prefill value of autcomplete textfield? can't find answer on documentation. have encounter same problem , able solve it?

example: creating form add/edit product. product depends on part. part using angucomplete.

when "editing product" angucomplete need prefilled part variable or data binding.

my code :

<div style="display:inline-block;" ng-repeat="part in productparts">         <!--<input type="text" />-->         <div angucomplete id="autocompletefield{{part.counter}}" placeholder="part" pause="100" selectedobject="partselectedobject" url="http//www.blablabla.com/part?keyword=" datafield="part" titlefield="name" minlength="2" inputclass="form-control form-control-small"></div>     </div> 

now when editing product, angucomplete needs prefilled object part.name

the solution have update plugin accept prefilled value.

in angucompletejs file in scope add :

"initialvalue": "@initialvalue"  

and in link add :

if($scope.initialvalue){             $scope.searchstr = $scope.initialvalue;         } 

now can use initialvalue attribute.

<div style="display:inline-block;" ng-repeat="part in productparts"> <div angucomplete id="autocompletefield{{part.counter}}" placeholder="part" pause="100" selectedobject="partselectedobject" url="http//www.blablabla.com/part?keyword=" datafield="part" titlefield="name" minlength="2" inputclass="form-control form-control-small" initialvalue="{{part.name}}"></div> </div> 

Comments