Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="MyCtrl">
Hello, {{name}}!
<span my-parent-control data-obj="testObj" ><span><span my-child-control></span></span></span>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
$scope.name = 'Superhero';
$scope.testObj = {name: "My Property"};
}
myApp.directive("myParentControl", function() {
return {
scope: {
obj: '='
}
};
});
myApp.directive("myChildControl", function() {
return {
controller: function($scope){
console.log($scope.obj.name);
},
link: function(scope, element, attrs) {
//Undefined
console.log(scope.obj.name);
}
}
})