【问题标题】:How to set the width of the dropdown in the typeahead module如何在预输入模块中设置下拉菜单的宽度
【发布时间】:2017-05-11 11:27:09
【问题描述】:

我试图了解如何将 Typeahead 模块中的下拉菜单设置为与输入文本具有相同的宽度,并且不会根据下拉菜单中内容的宽度动态更改。我正在使用 ng-bootstrap 的 1.0.0-alpha.15。

【问题讨论】:

    标签: angular-ui-bootstrap ng-bootstrap


    【解决方案1】:

    只需在下拉模板中添加宽度

    来自

    <template #rt let-r="result" let-t="term">
        <img [src]="'https://upload.wikimedia.org/wikipedia/commons/thumb/' + r.flag" width="16">
        {{ r.name}}
    </template>
    

    到

    <template #rt let-r="result" let-t="term">
        <div style="width: 350px;">
            <img [src]="'https://upload.wikimedia.org/wikipedia/commons/thumb/' + r.flag" width="16">
            {{ r.name}}
        </div>
    </template>
    

    Plunk

    如何将 Typeahead 模块中的下拉菜单设置为与输入文本具有相同的宽度

    恕我直言,这可能是个坏主意,但如果您不想要静态宽度,您可以calculate the input string width 并改用 NgStyle。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多