剑道自动完成与角服务器过滤,怎么样? [英] Kendo Autocomplete with server filtering in Angular, how to?

查看:109
本文介绍了剑道自动完成与角服务器过滤,怎么样?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我跟着这个例子说明了AngularJS与剑道自动完成基本工作。

I followed this example which describes basic working with Kendo Autocomplete in AngularJS.

问题是,例如仅适用于本地定义的数据。

Problem is that example works only with local defined data.

有人能张贴例子如何与远程JSON数据源的工作?

Could somebody post example how to work with remote JSON data source?

链接是:
http://demos.telerik.com/kendo-ui/autocomplete/angular

感谢您的任何建议。

推荐答案

只需使用$ HTTP,所以是这样的:

Just use $http, so something like this:

angular.module("KendoDemos", [ "kendo.directives" ]);
function MyCtrl($scope, $http){

$http.get('/remoteDataSource').
    success(function(data) {
        $scope.countryNames = data;
    });
}

如果数据被改变,因为你输入时,你可以使用$手表也:

If the data is changing as you type, you could use a $watch also:

angular.module("KendoDemos", [ "kendo.directives" ]);
function MyCtrl($scope, $http){

$scope.$watch('textboxValue', function(){
    $http.get('/remoteDataSource/' + $scope.textboxValue).
        success(function(data) {
            $scope.countryNames = data;
        });
    }
});

这篇关于剑道自动完成与角服务器过滤,怎么样?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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