使用 ng-options Angular binds/populates 下拉列表后触发事件

Fire event after Angular binds/populates dropdown using ng-options

我正在使用 bootstrap-multiselect 控件。一旦 Angular.

填充了所有选项,我需要在 select 元素上执行 multiselect()

这是绑定到 $scope 属性 的 select 框,其中的选项是从我看来的 accountInfo 对象片段数组生成的:

<select id="property" multiple="multiple" 
    ng-model="selectedProperty" 
    ng-options="account.property_name group by account.client_name for account in accountInfo">
</select>

所以一旦选项存在,我需要调用 $("#属性").multiselect() 来生成 bootstrap 控件,但我正在寻找一个要监听的事件会告诉我所有选项何时生成。

不要在控制器中初始化 bootstrap-multiselect 控件,而是在指令 link() 函数中执行此操作,该函数在呈现相应元素后调用。

app.directive('multiselect', function() {
  return {
    restrict: 'A',
    link: function(scope, element) {
      element.multiselect();
    }
  };
});

这是一个demo