Broadcast do not enter into the communication function

Here is my code

'use strict'; angular.module('app') .directive('item' , ["$timeout" , "$Service" , function( $timeout , $utils) { return { restrict: 'A', scope: { item: '=', }, transclude: true, link: function(scope, element, attrs, ctrl, transclude){ }, templateUrl: $fsUtils.getRelativeUrl('templates/item.html'), controller: 'ItemCtrl', }; }]); 

My index.html:

 <item><div>Transcluded content.</div></item> 

transclude variable is undefined and ctrl is proto__: Object . I need to enter the parent area in the cross-border area. The transition variable is undefined. Where am I mistaken.

My angular version is 1.1.5

Thanks.

+5
source share
1 answer

What you are looking for is transcludeFn. Try the following:

 transclude: true, transcludeFn: function () { /*do your stuff here*/ }, ... link: function(scope, element, attrs, controller, transcludeFn) 

To access the controller in the communication function, you can do this:

 var controller = scope.controller; 
0
source

All Articles