选择里面ngTable droplist失去了它的适用范围 [英] Selects droplist inside ngTable loses its scope

查看:245
本文介绍了选择里面ngTable droplist失去了它的适用范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我把选择(select.js)droplist内ngTable,并尝试从表外的显示选择,它失去了它的范围,并且不显示选择。但愿我能解释这个问题。

If I put the Selects (select.js) droplist inside ngTable, and try to show the selection from outside the table, it loses its scope and doesn't show the selection. Hopefully, I was able to explain this.

这里的preVIEW。在preVIEW,你会看到它有两个输出位置的选择droplist。其中一个工作表内,另一个则没有表外。

Here's the preview. In the preview, you will see a select droplist which has two output locations. One inside the table which works and another outside the table which doesn't.

http://plnkr.co/edit/tQYmRrTjXOhTohsESpNo?p=$p$ PVIEW

推荐答案

它的工作原理。这是我必须做的。我不得不修改角strap.js。添加范围。$适用(),以下面这段code的。

It works. Here's what I had to do. I had to modify the angular-strap.js. Add scope.$apply() to the following piece of code.

$select.update = function (matches) {
  scope.$matches = matches;
  if (controller.$modelValue && matches.length) {
    if (options.multiple && angular.isArray(controller.$modelValue)) {
      scope.$activeIndex = controller.$modelValue.map(function (value) {
        return $select.$getIndex(value);
      });
    } else {
      scope.$activeIndex = $select.$getIndex(controller.$modelValue);
    }
  } else if (scope.$activeIndex >= matches.length) {
    scope.$activeIndex = options.multiple ? [] : 0;
  }
  scope.$apply();
};

这篇关于选择里面ngTable droplist失去了它的适用范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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