angularjsangularjs-directiveangularjs-compile

Getting AngularJS multilink error after upgrade from v. 1.4


I have a big directive with sub-directives where I'm getting the error. Exactly, it happens on the step when calling transcludeFn() in the link function of main directive:

var link = function ($scope, elem, attr, parentCtrl, transcludeFn) {
            // Run all nested directives in order to properly register columns in grid.
            transcludeFn();

            // Add compiled content to directive element.
            elem.after($compile(template)($scope));
        };

Can't figure out with that issue. What I've missed in the docs? Adding stuff with $onInit as described here doesn't help (I'm not sure I was doing that correctly).

I'm not familiar with AngularJS so any help will be a good point.


Solution

  • I really don't know what is the root of the issue but I've solved it by passing a dummy function into transcludeFn():

    var link = function ($scope, elem, attr, parentCtrl, transcludeFn) {
        // Run all nested directives in order to properly register columns in grid.
        transcludeFn();
        transcludeFn(function() {
            // do nothing, only for fixing upgrade issue 
        });
    
        // Add compiled content to directive element.
        elem.after($compile(template)($scope));
    };