title: Angular. restrict: 'A' directive. Pass object
body: <p>Is there a way to pass configuration object into custom directive which defined as a attribute-directive?</p>
  
  <p>I've got an object in Controller that I want to send to directive:</p>
  
  <pre><code>$scope.configObject = {
      count: 5,
      mode: 'fast',
      getData: myService.getData // function of external service that avaliable in controller
  }
  </code></pre>
  
  <p>In my View I declare directive:</p>
  
  <pre><code>&lt;div class='list-class' my-list='configObject'&gt;&lt;/div&gt;
  </code></pre>
  
  <p>Directive looks like:</p>
  
  <pre><code>return {
      restrict: 'A',
      link: function(scope, elem, attrs) {
          var config = angular.fromJson(attrs.myList);
      }
  }
  </code></pre>
  
  <p>i've tried to get config object using angular.getJson - but it doesn't work for functions (it's possible to get only count and mode). Is .getJson() the incorrect way to get config?</p>
  
  <p>Also (I guess it's not even possible) - is there a way to get config object avoiding accessing to</p>
  
  <pre><code>attrs.myList
  </code></pre>
  
  <p>directly? I mean if I change initializing of directive from</p>
  
  <pre><code>.directive('myList', function() { ... }) to
  .directive('myCustomList', function() { ... })
  </code></pre>
  
  <p>shall I change accessing to</p>
  
  <pre><code>attrs.myCustomList
  </code></pre>
  
  <p>because view would look like</p>
  
  <pre><code>&lt;div class='list-class' my-custom-list='configObject'&gt;&lt;/div&gt;
  </code></pre>