Closed sasyomaru closed 9 years ago
I've created a pull request to fix this problem (#20). Hopefully it will fix the issue. Would appreciate very much if you could have a look at it.
Thanks @sasyomaru! I believe this is the source of various the issues with controllers others have been having.
We're in need of a fix for this. Is the PR #20 the way a fix should be, @zachsnow?
At least it seems to work for the issue above (which is the same we have) :).
@sasyomaru I played with this a little and it seems that we don't even need the hidden container, we can simply attach the transcluded content directly to the element, and then the link functions will move the content into the correct places.
@rainboxx it does indeed work, I just want to find the minimal solution possible (which this may well be).
@zachsnow I appreciate your investigation!
I found out that this PR will not fix all issues that we're having. Our directive using the multi-transclude
also adds a form
to the DOM. With a normal transclude
we're able to access the form from within the transcluded content. Using the multi-transclude
we cannot access that scope and therefor are unable to get our hands to the FormController
.
@rainboxx interesting, any chance you can sketch out more precisely what you mean?
I can try to make a jsfiddle tomorrow, I'm about to leave for bed now (UTC+1).
@rainboxx thanks very much.
@sasyomaru I suppose we could add ng-hide
during the initial transclude and then remove it when moving the individual components to the correct place if there's a worry about flashing content perhaps? It seems it should be batched though.
The flashing content is also what I concerned most. But adding ng-hide may have conflict if the directive user already add ng-hide (for example, to show the template only under some condition).
@sasyomaru you make a good point re: ng-hide
. Ok, we'll use a nested container with ng-hide
and remove the container when all of its content has been moved to the right position.
It seems we should be able to get rid of this:
$scope.$on('$destroy', function(){
if(toTransclude){
toTransclude.remove();
toTransclude = null;
}
});
Because toTransclude
stays in the DOM now, and so already be removed when the scope is destroyed, no?
I've updated master
to include these ideas.
@zachsnow Sorry for the delay, kids got sick and we had to work on some different stuff first. I no longer think my issue is related to this so I opened another issue, #23. Thanks!
I'm using ng-multi-transclude in a website and find an issue on the disconnection of transclude content and the context. For example,
When running the code, there will be an error "[$compile:ctreq] Controller 'form', required by directive 'belowForm', can't be found!" and the template is not filled correctly. This is because the controller doesn't append the transclude content into its context until ctrl.transclude is called, but the link of directive happens in $transclude, which makes the content lost the context.