title: Karma/Jasmine passing objects to custom directive and access it
body: <pre><code>(function () {
      'use strict';
  
      describe('TestButton', function () {
      var controller, element, util;
  
      beforeEach(function () {
          module('app');
          module('template');
          module('TestUtil');
  
          inject(function (TestUtilService) {
              util = TestUtilService;
  
              var testFunc = function foo(){
                  return 5;
              };
  
              // Passing the defined function to the custom directive and call it via 
              // controller.clickButton (it will be fired there)
              // function=\' + testFunc + '" passing the function as string also not working
              element = '&lt;custom-button id="btn1" label="Click Me" function="testFunc"&gt;&lt;/custom-button&gt;';
  
              element = util.compileElement(element);
              controller = util.getController(element, 'customButton');
          });
      });
  
      it('should be resolved', function () {
          expect(element.html()).toContain('input');
      });
  
      it('should be set', function () {
          expect(element.find('input').val()).toBe('Click Me');
      });
  
      it('should be set', function () {
          expect(element.find('input').attr('id')).toContain('button_btn1_');
      });
  
      it('should fire the passed function', function () {
          //controller.clickButton() should log 5 or something, but its not working at all
          //controller itself is working perfect (I have access to the whole directive-scope)
      });
  });
  </code></pre>
  
  <p>TestUtilService :</p>
  
  <pre><code>this.compileElement = function (element) {
      var el = vm.$compile(element)(vm.$scope);
      vm.$scope.$digest();
      return el;
  };
  
  
  this.getController = function (element, directiveName) {
      return element.controller(directiveName);
  }
  </code></pre>
  
  <p>How can I pass an object to the directive, compile it and access it. I also have problems with passing arrays or something. How does that work in Karma/Jasmine??</p>
  
  <p>Would be wonderful, if someone could give me some tips.</p>