【问题标题】:Placeholder is not working in angularjs select2占位符在angularjs select2中不起作用
【发布时间】:2013-12-18 16:48:21
【问题描述】:

这是我尝试过的代码。我尝试使用 angularjs 代码和 html 代码添加占位符,但在这两种情况下都不起作用。请帮助我或建议我在这种情况下该怎么做

 <select ui-select2="select2Options" 
style="width:100%" 
ng-model="SelectedProcessandIngredients"
 data-placeholder="Select or Add Process/Ingredient" 
ng-options="c.name group by c.status for c in colors"
 ng-change="selectedinnerLoop()" >          
        </select>

Angular js 代码:

$scope.select2Options = {
        placeholder : "Select or Add Process/Ingredient",
        formatResult : processList,
        formatSelection : processList,
        escapeMarkup : function (m) {
        return m;
        }

    };

【问题讨论】:

  • 我认为它现在适用于最新版本。

标签: angularjs angularjs-select2


【解决方案1】:

在你的选择标签内添加一个空的选项标签,占位符就会显示出来。 此外,使用 ng-repeat 代替 ng-options。 Select2 与 ng-options 不兼容。

<select ui-select2 ng-model="select2" data-placeholder="Pick a number">
    <!-- empty option gets placeholder working -->
    <option value=""></option>
    <!-- ng-repeat to populate dynamic options -->
    <option ng-repeat="number in range" value="{{number.value}}">{{number.text}}</option>
</select>

【讨论】:

  • 它也对我有用,但国际化不起作用
猜你喜欢
  • 2018-02-19
  • 2014-03-04
  • 2015-03-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-09-22
  • 2016-10-04
  • 2013-10-19
相关资源
最近更新 更多