Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html ng-app="app">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.14/angular.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body ng-controller="MainController">
   <a-dir info="info">
       <e-dir></e-dir>
   </a-dir>
</body>
</html>
 
angular.module('app', [])
.controller('MainController', function ($scope) {
    $scope.info = 'I am info';
})
.directive('aDir', function () {
    return {
       restrict: 'E',
       transclude: true,
       template: '<p>aDir: {{info}}<span ng-transclude></span></p>',
       scope: {
         info: '='
       },
       controller: function ($scope) {
          this.getInfo = function () {
              return $scope.info;
          };
       },
       link: function (scope, elm, attrs) {
         
       }
    };
})
.directive('eDir', function () {
    return {
       restrict: 'E',
       template: '<p>eDir: {{info}}</p>',
       require: '^aDir',
       scope: { },
       link: function (scope, elm, attrs, aDirController) {
            scope.$watch(function () {
              return aDirController.getInfo();
            }, function (newVal, oldVal) {
                scope.info = newVal;
            });
       }
    };
});
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers