AngularJS:在没有匹配项时更改Angular-chosen插件的占位符文本

时间:2018-09-11 12:58:57

标签: html angularjs angular-chosen

从标题中可以看到,我试图更改占位符文本,该文本显示为“没有结果匹配”,并且从选定标签中变灰(禁用)。

我尝试使用“占位符”,但是不起作用。

<div>
    <select chosen disable-search="true" id="newpaymentMethod"
            placeholder="Placeholder text"
            class="easytrade-input full-width" name="newpaymentMethod"
            ng-model="vm.newRecord.paymentMethod"
            ng-options="paymentMethod.type as paymentMethod.description
                for paymentMethod in vm.paymentMethodOptions"
            required>
    </select>
</div>

然后我尝试使用“ no_results_text”,但仍然无法正常工作

<div>
    <select chosen disable-search="true" id="newpaymentMethod"
            no_results_text="Placeholder test"
            class="easytrade-input full-width" name="newpaymentMethod"
            ng-model="vm.newRecord.paymentMethod"
            ng-options="paymentMethod.type as paymentMethod.description
                for paymentMethod in vm.paymentMethodOptions"
            required>
    </select>
</div>

有什么想法吗? 谢谢

1 个答案:

答案 0 :(得分:0)

检查Angular-Chosen的GitHub文档后,我发现了如何使用“ no_result_text”。

请参见下面的代码:

<div>
    <select chosen disable-search="true" id="newpaymentMethod"
            no-results-text="'Placeholder test'"
            class="easytrade-input full-width" name="newpaymentMethod"
            ng-model="vm.newRecord.paymentMethod"
            ng-options="paymentMethod.type as paymentMethod.description
                for paymentMethod in vm.paymentMethodOptions"
            required>
    </select>
</div>

因此,您必须使用“ no-results_text”而不是“ no_results_text”,并且该文本也应以''换行,就像下面的“'text here'”“

希望将对我的回答有所帮助:)