【问题标题】:md-select on hover open select optionsmd-select 悬停打开选择选项
【发布时间】:2015-08-23 17:49:27
【问题描述】:

鼠标悬停时是否可以展开 md-select?

例如,我希望此状态选择在鼠标悬停时展开

http://codepen.io/anon/pen/vOmQgj

<md-select placeholder="State" ng-model="ctrl.userState">
        <md-option ng-repeat="state in ctrl.states" value="{{state.abbrev}}">{{state.abbrev}}</md-option>
</md-select>

【问题讨论】:

  • 在他们的文档中没有选项。但我认为您可以编辑他们的 md-select 指令来这样做。这有点难,但可以做到。
  • 我没有资格完成这个功能。有接盘侠吗? :)

标签: css angularjs angular-material


【解决方案1】:

目前不支持此功能,我有点怀疑它是否会添加到 md-select 组件中 - 尽管无论如何您都应该在 Github 中打开一张票,并说明您的用例。

这个功能更有可能存在于今天添加的新md-menu 组件中:https://material.angularjs.org/0.10.0-rc1/#/demo/material.components.menu

无论哪种方式,我都会打开 Github 票进行讨论。


话虽如此,我整理了一个可能对您有用的快速解决方案。

更新的 CodePen:http://codepen.io/robertmesserle/pen/qdmQpp

这使用以下 HTML:

<md-select
    placeholder="State"
    ng-model="ctrl.userState"
    ng-mouseenter="ctrl.handleMouseEnter($event)">
  <!-- content -->
</md-select>

还有handleMouseEnter 方法:

this.handleMouseEnter = function (event) {
  angular.element(event.target).triggerHandler('click');
}

【讨论】:

  • 我在页面上有多个 md-select。选择一个后,我需要下一个按顺序自动打开,您的解决方案就是解决方案。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-22
  • 1970-01-01
  • 1970-01-01
  • 2019-03-25
  • 1970-01-01
  • 2017-06-19
相关资源
最近更新 更多