Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-app="app">
  <server>
    <client></client>
    <client></client>
    <client></client>
  </server>
</body>
</html>
 
var app = angular.module("app", []);
app.directive("server", function() {
  return {    
    controller: function($element) {                 
      count = $element.find("client").length;
      this.call = function() {
        console.log("Server has been called");
        count --;
        if (count === 0) {
          console.log("All of them are initialized");
        }
      };
    }
  };
});
app.directive("client", function() {
  return {
    require: "^server",
    link: function($scope, $elem, $attrs, serverCtrl) {
      serverCtrl.call();
    }
  };
});
Output 300px

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