title: Angular append an element to the child of current element inside of a directive
body: <p>I am trying to append an element to a child element inside of a directives element. So I have this code:</p>
  
  <pre><code>directives.group = function ($compile) {
      return {
          restrict: 'E',
          templateUrl: '../../Content/templates/RecruitingGroups/Group.html',
          link: function (scope, el) {
              scope.addRule = function () {
                  var rule = $compile('&lt;rule&gt;&lt;/rule&gt;')(scope);
                  $(el).find('#rule').append(rule);
              }
          }
      }
  }
  </code></pre>
  
  <p>Notice in the link I have a function(). The function has scope and element passed into it. I thought 'el' would be unique and would be like doing a jQuery <code>addRule($this)</code>. But it appears this is not the case because if several of these <code>&lt;group&gt;</code> divs are on the page the code  <code>$(el).find('.getGroups').append(rule)</code> will append to the last instance of that element on the page. Not to <code>$this</code> like I imagined it would work. </p>
  
  <p>My problem is how do I append this <code>&lt;rule&gt;</code> element to <code>this</code> directive. Not another one an the page.</p>
  
  <p>Some Example HTML</p>
  
  <pre><code>&lt;div&gt;
      &lt;group&gt;
          &lt;div ng-click="addRule()"&gt;
              &lt;div id="rule"&gt;
                  &lt;rule&gt;&lt;/rule&gt;
                  &lt;rule&gt;&lt;/rule&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/group&gt;
      &lt;group&gt;
          &lt;div ng-click="addRule()"&gt;
              &lt;div id="rule"&gt;
                  &lt;rule&gt;&lt;/rule&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;/group&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>So in other words When I click <code>addRule()</code> I want it to append the <code>&lt;rule&gt;</code> element to the child <code>id="rule"</code> where you currently clicked the <code>addRule()</code> button.</p>