ui select angularjs set maxlength for input value (ui select match)

后端 未结 3 1304
刺人心
刺人心 2021-01-25 07:26

I want an extra attribute just like \"Placeholder\" is passing from ui select match. I want to set maxlength of select input. I can set it through select.min.js adding attribute

相关标签:
3条回答
  • 2021-01-25 07:49

    As per my understanding, you are using ui-select with tagging (as combo-box).

    in this to achieve your desired functionality:

    go to ui-select plugin.js and edit the template "select2/select.tpl.html" (for theme select2):

    ng-attr-maxlength="{{$select.tagging.isActivated ? 50 : ''}}"

    add the above line to template as shown here:

    <input type=\"search\" ........... ng-attr-maxlength=\"{{$select.tagging.isActivated ? 500 : ''}}\">
    

    if you want to restrict input search itself then directly add maxlength attribute:

    <input type=\"search\" ........... maxlength=\"500\">
    

    Hope this helps. :-)

    0 讨论(0)
  • 2021-01-25 08:05

    You can limit your collection using the angular's limitTo filter. Look at the limitTo reference.

    0 讨论(0)
  • 2021-01-25 08:12

    You can change attribute through templateCache

    .run(function($templateCache) {
            $templateCache.put("bootstrap/select-multiple.tpl.html","<div class=\"ui-select-container ui-select-multiple ui-select-bootstrap dropdown form-control\" ng-class=\"{open: $select.open}\"><div><div class=\"ui-select-match\"></div><input maxlength='5' type=\"search\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$selectMultiple.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\" role=\"combobox\" aria-expanded=\"{{$select.open}}\" aria-label=\"{{$select.baseTitle}}\" ng-class=\"{\'spinner\': $select.refreshing}\" ondrop=\"return false;\"></div><div class=\"ui-select-choices\"></div><div class=\"ui-select-no-choice\"></div></div>");
        })
    

    Original templates can be find on bottom of file select.js

    0 讨论(0)
提交回复
热议问题