title: AngularJS - Can I change the value / expersion of ng-repeat in View using a directive
body: <p>I have a hypothetical question. Say I have two object arrays in my Controller and in my view I loop through the data of one of these object arrays. Now is it possible for me to switch the value of this ng-repart (or change the expression) in a directive. For example...</p>
  
  <p>here is my controller:</p>
  
  <pre><code>controller('MainCtrl', ['$scope', function($scope) {
              $scope.beatles = [{id:1, name: "John", inst: "Guitar", alive: false},{id:2, name: "Paul", inst: "Bass", alive: true},{id:3, name: "George", inst: "Guitar", alive: false},{id:4, name: "Ringo", inst: "Drums", alive: true}];
  
              $scope.huskers = [{id:1, name: "Bob", inst: "Guitar", alive: true},{id:2, name: "Grant", inst: "Drums", alive: true},{id:3, name: "George", inst: "Bass", alive: true}];
      }])
  </code></pre>
  
  <p>Here is my view... </p>
  
  <pre><code>&lt;div data-my-template-dir class="beatles"&gt;
          &lt;div data-ng-repeat="beatle in beatles track by $index"&gt;
            Name: {{beatle.name}}, Instrument: {{ beatle.inst }}
          &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here is my directive...</p>
  
  <pre><code>restrict: 'A',
  link: function (scope, element) {
    element.bind('click', function () {
       console.log('i am clicked');
       element[0].children[0].setAttribute('data-ng-repeat','beatle in huskers track by $index');
       // something should go here... like scope.apply() ???? 
  });
  </code></pre>
  
  <p>Now, it seems that the directive does work with the model/ctrl... but the HTML doesn't seem to update in the view... am I going about this wrong, can I update the ng-repeat in the directive?</p>
  
  <p>I have a plunker (or jsbin) here: <a href="https://jsbin.com/fasako/edit?html,output" rel="nofollow">https://jsbin.com/fasako/edit?html,output</a></p>