title: Angularjs : Call directive method as callback from controller
body: <p>I have a directive that uses a jquery "multiselect" plugin to enhance any &lt; select > with an attribute of "filtermultiselect". My problem is the select is populated via an ajax call and I don't want the directive to run until the &lt; select > has been populated. I amended my directive as follows</p>
  
  <pre><code>angular.module('filtermultiselectDirective', [])
      .directive('filtermultiselect', function() {
          return {
              restrict: 'A',
              link: function( $scope, element, attrs ) {
  
              $scope.$on('createMultiSelectFilters', function (element) {
                  element.multiselect({
                      disableIfEmpty: true,
                      buttonWidth:'100%',
                      enableFiltering: true,
                      includeSelectAllOption: true,
                      enableCaseInsensitiveFiltering: true                    
                  });
              });
          }
      }
  });
  </code></pre>
  
  <p>and from my controller I simply use </p>
  
  <pre><code>$scope.$broadcast('createMultiSelectFilters');
  </code></pre>
  
  <p>as a callback. However, doesn't work, I get "element.multiselect is not a function".</p>
  
  <p>Any advice for a novice?</p>