angularjsangularjs-directiveangularjs-ng-repeatangularjs-ng-transclude

How to get ng-repeat item inside transcluded template?


How I can use ngRepeat item inside transcluded template? Is it possible?

Directive template:

<ng-transclude ng-repeat="record in records | filter1 | filter2"></ng-transclude>

Directive:

  app.directive('myDirective', function () {
    return {
      templateUrl: '/views/directives/mydirective.html',
      restrict: 'A',
      transclude: true,
      scope: {
        records: '='
      }
    };
  });

Controller view:

<div my-directive records="myRecords">
  {{ myDirective.record }}
</div>

Solution

  • Doesn't look like it from the way you're doing it.

    But you can $compile the template in the directive to achieve this.

    http://jsbin.com/mirisixodo/edit?html,js,console,output