Click here to Skip to main content
15,886,003 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi
I am currently trying to implement a autocomplete textbox(when user starts typing in the textbox, based on characters entered data will be returned to the UI from the database) in using Angular JS and MVC 5. The data being returned is not the database i am connecting to through the entity framework, it is a webservice that i am calling

So <i have added my control to the pa
HTML
<label class="control-label">Customer Search</label>
                        <input Customer-auto-complete class="form-control" ng-model="ctrl.Customer" placeholder="enter name" type="text">  


In my function, how would i make the datasource a list which is returned from a webservice call?

The webservice will be called from the customer controller through public actionresult called GetCustomers

What I have tried:

This is the function i have found and currently have implemented

JavaScript
function customerCtrl($scope) {

               var ctrl = this;
               ctrl.client ={name:'', id:''};
               $scope.dataSource = [{name:'Ragnar'},{name:'Helga'},{name:'Bucky'},{name:'Renato'},{name:'Bojan'}, {name:'Ricardo'}, {name:'Oviedo'];

               $scope.setClientData = function(item){
                    if (item){
                        ctrl.Customer= item;
                    }

               }
           }
Posted
Updated 29-Aug-16 21:30pm
v2
Comments
Nathan Minier 30-Aug-16 7:30am    
We won't be able to help much without knowing any details about the "Customer-auto-complete" directive.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900