0

我正在使用带有 Angular 的 selected-bower 安装,但每次在我的服务器上运行应用程序时,我都会得到“element.chosen 不是函数”。jQuery 是在 Angular 之前定义的,当我在加载后运行 $('select').chosen() 时,它工作正常。它必须与指令加载方式有关。

我的指令如下:

.directive('chosen', function($timeout) {

  var linker = function(scope, element, attr) {

    $timeout(function () {
      element.chosen({
        placeholder_text_single: "-- select venue --"
      });
    }, 0, false);
  };

  return {
    restrict: 'A',
    link: linker
  };
});

编辑:我想指出,当我使用 grunt serve 时,这完全可以正常工作

4

1 回答 1

0

尝试安装 selected 并将其包含在 jquery 之后。

于 2016-08-04T11:23:34.863 回答