KendoAutoComplete无法与指令

时间:2019-01-30 10:09:27

标签: javascript angularjs kendo-ui autocomplete

我们将KendoAutoComplete用于Angular 1.7应用程序。 我们在控制器promise中的$ scope中有列表,并希望将其与autocomplete一起使用。

解决承诺的控制器的以下代码,

manualOrderApp.controller('myselection', ['$scope', "dfactory", "mservice", function ($scope, dfactory, mservice) {
$scope.errorMessage = null;

$scope.cusotmerPromise = null;

var init = function () {
    $scope.cusotmerList = null;
    $scope.cusotmerPromise = mservice.getCustomerList(dfactory.customer.CustomerNumber).then(function (results) {
        $scope.cusotmerPromise = null;
        $scope.cusotmerList = results;
    });
    $scope.showTheme = false;
}

init();

}]);

以下是绑定kendoautocomplete的指令的代码,

manualOrderApp.directive('customersearch', ['mservice', 'dfactory', function (mservice, dfactory) {
return {
    restrict: 'AE',
    replace: true,
    scope: {
        customers: '='
    },
    link: function ($scope) {
        var abc = typeof $scope.licenses !== 'undefined' ? $scope.licenses : true;           
        var customersearchbar = $("#customersearchbar").kendoAutoComplete({
            dataTextField: "Title",
            filter: "contains",
            minLength: 1,
            dataSource: {
                data: $scope.customers,
                serverFiltering: true                 
            }
    }
}

}]);

现在,从视图中,我们定义了这些模板,

<div class="container" ng-controller="myselection">
<div class="content">
    <header>
        <h1>search</h1>
            <customersearch customers="cusotmerList"></customersearch>

    <section>
        <div cg-busy="{promise:cusotmerPromise,message:'fetching',backdrop:false,delay:100,minDuration:300}"></div>
        <customerDetail customers="cusotmerList"></customerDetail>
    </section>
</div>

现在的问题是,当promise解决后,绑定kendoautocomplete的指令将在调用$ scope.customers null的早期调用。

程序执行如下, 控制首先是在promise上进行,然后是在发现客户为空的指令上,然后在promise中解决了客户被填满的问题。

有什么建议吗?

0 个答案:

没有答案