Bootstrap-select角度指令不起作用

时间:2016-06-16 03:53:21

标签: javascript angularjs angular-directive

我正在使用{em> silvio moreto bootstrap-select。但是,在角度填充数据之前已加载 selectpicker

所以我试图创建一个指令,在angular填充数据之后刷新 selectpicker 本身。

这是脚本:

(function() {
    'use strict';

    angular.module('myapp')
        .directive('selectPicker', selectPicker);

    function selectPicker($timeout) {
        return {
            restrict: 'A',
            link: function(scope, elem) {
                $timeout(function() {
                    elem.selectpicker('refresh');
                }, 0);
            }
        };
    };

})();

我在select标记中将其用作

<select ng-model="add.doctype" class="form-control selectpicker with-search" selectPicker data-live-search="true" title="" data-container="body" ng-options="x.tipe for x in ::Doctypes" ng-change="Newdocno()">
    <option value=""></option>
</select>

它没有任何效果。指令有问题吗?

1 个答案:

答案 0 :(得分:0)

我找到了存储库https://github.com/joaoneto/angular-bootstrap-select,但它已被弃用,但可以为您提供帮助。

相关问题