title: Passing id and as a parameter to directive
body: <p><a href="http://jsfiddle.net/mato75/t48qn/" rel="nofollow">http://jsfiddle.net/mato75/t48qn/</a></p>
  
  <p>I have a directive, that if id is not passed, then it should generate one, but it looks like that the generation is to slow and the id is not present in the directive.</p>
  
  <pre><code>(function (angular) {
  'use strict';
  
  angular.module('Widgets.Module')
  .directive('myDirective', [
      function () {
          function postLink(scope, jqElm, attr) { }
  
          function postCompile(tElement, tAttrs) {
              return function postLink(scope, jqElm, attr) {
                  attr.$observe("id", function (id) { // called on on init
                      scope.id = id !== undefined ? id : 'something 1';
                  });
              }
          }
  
          function Ctrl(scope) {
          }
  
          return {
              template:
                  '&lt;div id="{{ id }}"&gt;' +
                  '&lt;/div&gt;',
              controller: [
                  '$scope', Ctrl
              ],
              replace: true,
              scope: {
                  id: '@'
              },
              restrict: 'AC',
              link: postLink,
              compile: postCompile
          };
  
      }
  ])
  ;
  })(window.angular)
  </code></pre>