Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app='testApp'>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body ng-controller="testCtrl">
    <my-table table-id="table1">
        <div ng-repeat="row in table.rows" repeat-done target="table1"></div>
    </my-table>
  
</body>
</html>
 
var directives = angular.module('my.directives',[]);
var app = angular.module('testApp',['my.directives']);
app.controller('testCtrl',function($scope){
  console.log('in testCtrl');
  $scope.table = {
    rows: [
      1,2,3,4
    ] 
  };
});
angular.module('my.directives')
.controller('myTableCtrl', function($scope, $element, $attrs) {
    console.log('in table Ctrl');
            var self = this;
            $scope.tableUID = $attrs.tableId;
            self.tableLoaded = function(){
                console.log("Table Loaded");
            };
            console.log('tableUID' + $scope.tableUID);
            $scope.$on('repeat-done-' + $scope.tableUID, function(event,args){
              console.log('in catcher function');
                self.tableLoaded();
            });
})
.directive('myTable', function() {
    return {
        restrict: 'EA',
        controller: 'myTableCtrl as myTable'
    };
})
.directive('repeatDone', function($timeout) {
        return {
            restrict: 'EA',
            link: function(scope, element, attrs) {
              console.log('in directive');
                var targetUID = attrs.target;
              console.log(targetUID);
                if (scope.$last) {
                    $timeout(function(){
                       
                      console.log('repeat-done now');//scope.$eval(attrs.repeatDone);
                        scope.$emit('repeat-done-' + targetUID,{});
                    });
                }
            }
        };
    });
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers