Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<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-app="problem">
<button ng-click="hola()">HOLA</button>
  <parent>
    <child item="pctrl.item"></child>
  </parent>
</body>
</html>
 
angular.module('problem', [])
  .directive('parent', parent)
  .directive('child', child);
function parent() {
  return {
    restrict: 'E',
    template: '<div><div><input type="text" ng-model="item"/><button ng-click="pctrl.hola()">HI</button></div><ng-transclude></ng-transclude></div>',
    controllerAs: 'pctrl',
    transclude: true,
    controller: function($scope) {
      $scope.item = 35;
      $scope.hola = function() {
        $scope.item = $scope.item + 1;
      };
    }
  };
}
function child() {
  return {
    restrict: 'E',
    scope: {
      item: '='
    },
    template: '<div><div><input type="text" ng-model="cctrl.item2"/><div></div></div></div>',
    bindToController: true,
    controllerAs: 'cctrl',
    controller: function() {
      this.item2 = this.item + 25;
    }
  };
}
Output 300px

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

Dismiss x
public
Bin info
anonymouspro
0viewers