The transcluded content is bound to the scope in which the directive lives,
not the isolated scope. So `message` is not available there.

On 21 June 2015 at 05:22, Thiago Rizzo <[email protected]> wrote:

> Hello,
>
> I just made an example of how I am trying to use transclude data binding.
> Well, after binding an object (message) from controller scope its
> "undefined" in link function.
>
> <html ng-app="myApp">
>  <head>
>  <script src="
> https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js";
> ></script>
>
>
>  <script>
>  angular.module('myApp', []).controller('myAppController', function($scope
> )
>  {
>  $scope.message = { text: 'hello'}
>  });
>
>
>  angular.module('myApp').directive('myDirective', function() {
>             return {
>  restrict: 'E',
>         template: "<div><div ng-transclude></div></div>",
>         transclude: true,
>         scope: { message: "=" },
>         link: function (scope) {
>          // Its "undefined" here
>          console.log(scope.message);
>         }
>     };
>  })
>  </script>
>
>
>  </head>
>
>
>  <body ng-controller="myAppController">
>       <my-directive>
>            {{message.text}}
>        <my-directive>
>  </body>
> </html>
>
>
> Any help would be appreciated, Thanks
>
> Regards, Thiago Rizzo
>
> --
> You received this message because you are subscribed to the Google Groups
> "AngularJS" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/angular.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to