Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div ng-controller="TestCtrl">
    <h3>test</h3>
    <div my-directive records="myRecords">
      ?: {{record}}
    </div>
    
  </div>
</body>
</html>
 
var app = angular.module('app', [])
  .controller('TestCtrl', function($scope) {
    $scope.myRecords = ['foo', 'bar', 'baz'];
  });
app.directive('myDirective', function ($compile) {
    var transclude,
        template = '<div id="inner-transclude" ng-repeat="record in records"></div>';
  
    return {
      scope: {
        records: '='
      },
      restrict: 'A',
      compile: function(ele) {
        transclude = ele.html();
        ele.html('');
        
        return function(scope, elem) {
          var tpl = angular.element(template);
          tpl.append(transclude);
          
          $compile(tpl)(scope);
          
          elem.append(tpl);
        };
      }
    };
  });
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers