Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  <div ng-app="myApp" ng-controller="MyCtrl as d">
    <div ng-controller="ff as g">
      <div first="g.y.$data"></div>
    </div>
  </div>
</body>
</html>
 
var app = angular
  .module('myApp', [])
.controller('MyCtrl', function ($scope,$timeout) {
    $scope.x=1;
    this.y={d:2,c:5};
});
app.controller('ff', function ($scope,$timeout) {
    $scope.x=1;
  function fx(){
    this.$data=5;
  }
    this.y=new fx();
});
app.directive('first', function () {
    'use strict';
    return {
        restrict: 'A',
        replace : false,
        /*controller: function ($element) {
          //console.log('controller')
        },*/
      compile: function(tElem, tAttrs){
        console.log("compile");
        //tElem.append("test");
        return {
          pre: function(scope, iElem, iAttrs){
            
            console.log('preLink');
          },
          post: function(scope, iElem, iAttrs){
            
            var x= scope.$eval('g.y.$data');
            console.log(x);
            //iElem.append(x);
            console.log('postLink');
          }
        }
      },
        /*controllerAs: 'secondCtrl',
        bindToController: {
            second: '@'
        }*/
    };
});
Output

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

Dismiss x
public
Bin info
mr-rahimipro
0viewers