【问题标题】:Bootstrap-select angular directive not working引导选择角度指令不起作用
【发布时间】:2016-10-17 09:44:25
【问题描述】:

我正在使用 silvio moretobootstrap-select 和 angular。但是 selectpicker 在角度填充数据之前已加载。

所以我试图创建一个指令,在角度填充数据后刷新 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>

它没有任何作用。指令有问题吗?

【问题讨论】:

  • 如果您遇到控制台错误,可能是因为您在 angular.module('myapp) 上缺少单引号
  • 对不起,更新了我的问题,与单引号无关,控制台没有错误。
  • 你能创建一个 JSFiddle 吗?

标签: javascript angularjs angular-directive


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多