只在角选择应用剑道DropDownList的风格 [英] Apply kendo dropdownlist style only on angular select

查看:166
本文介绍了只在角选择应用剑道DropDownList的风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个选择正在被使用填充角度绑定。

I have a select which is being populated using angular binding.

<选择类='clsBucket'ID​​ ='optBuckets'NG选项= NG-模式水桶opt作为opt.name对于选择'='bucketSelected'NG-变化='changeBucket()'>

<select class='clsBucket' id='optBuckets' ng-options='opt as opt.name for opt in buckets' ng-model='bucketSelected' ng-change='changeBucket()'>

现在我想申请这个选择剑道DropDownList的风格,但我不希望使用填充数据源剑道等选项,并继续认为采用了棱角分明的事情。

Now i want to apply the Kendo dropdownlist style on this select , but i don't want to populate the options using kendo datasource etc and continue to do that using angular.

如果我使用$('#optBuckets')。kendoDropDownList(),然后我得到应用requiired风格,但绑定数据丢失。

If i use $('#optBuckets').kendoDropDownList() then i get the requiired style applied but the binding data is lost.

为了解决任何帮助是非常AP preciated。

Any help in order to resolve that is highly appreciated.

推荐答案

以上code列出了水桶作为数据源。考虑到这一点,从而赋予水桶到示波器的承诺应该有它的承诺暴露的范围。从那里,一个指令可以访问它(这里称为bucketsPromise')

The above code lists "buckets" as the data source. With that in mind, the promise which assigns 'buckets' to the scope should have it's promise exposed on the scope. From there a directive can access it (here called 'bucketsPromise')

在控制器中的code可能看起来像这样的:

The code in the controller may look like such:

$scope.bucketsPromise = bucketsService.get().then(function(data) {
  $scope.buckets = data;
}).promise;

该指令会出现这样:

The directive will the appear as such:

.directive('angularToKendoDropdown', function() {
  return {
    scope: {
      'bindToCtrl': '&dataSourcePromise'
    },
    link: function(scope, element, attr) {
        scope.bindToCtrl.then(function() {
          $(element).kendoDropDownList();
        })
    }
 };
});

给出的选择将显示为这样的:

The given select would appear as such:

<select class='clsBucket angular-to-kendo-dropdown' id='optBuckets'
        ng-options='opt as opt.name for opt in buckets'
        ng-model='bucketSelected' ng-change='changeBucket()'
        data-source-promise='bucketsPromise'>
</select>

这篇关于只在角选择应用剑道DropDownList的风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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