如何使用angular js调用webservice返回arraylist [英] How do I call webservice to return an arraylist using angular js

查看:254
本文介绍了如何使用angular js调用webservice返回arraylist的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我目前正在尝试实现自动填充文本框(当用户开始在文本框中键入时,根据输入的字符数据将从数据库返回到UI)使用Angular JS和MVC 5.返回的数据不是我通过实体框架连接的数据库,它是我正在调用的web服务



So< ;我已将我的控制添加到pa

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

<label class="control-label">Customer Search</label>
                        <input Customer-auto-complete class="form-control" ng-model="ctrl.Customer" placeholder="enter name" type="text">  





在我的函数中,如何使数据源成为从Web服务调用返回的列表?



将通过公共actionresul从客户控制器调用webservice叫做GetCustomers



我尝试过:



这是功能我已找到并且目前已实现





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

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;
                    }

               }
           }

推荐答案

scope){

var ctrl = this ;
ctrl.client = {name:' ',id:' '};
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.dataSource = [{name:'Ragnar'},{name:'Helga'},{name:'Bucky'},{name:'Renato'},{name:'Bojan'}, {name:'Ricardo'}, {name:'Oviedo'];


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

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


这篇关于如何使用angular js调用webservice返回arraylist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆