md-checkbox throws [ngTransclude:orphan] when used inside a directive using transclusion
Here is the error that get's reported.
Error: [ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element:
Will try and get a plunker setup to demo this. Though may take me sometime. For now I just wanted to get the error in.
I'm gonna close this. Try it with the newest version and the newest Angular.
Please reply if you keep finding issues.
Hi, I just tried it with the latest version and Angular 1.3.8. Still throws the same error.
Error: [ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found. Element:
@ACDN - if you provide a Plunkr or CodePen that demonstrates this issue, we will reopen and address it.
Will try to. Is there a plunkr that I could use as a starting point?
On Wed, Jan 14, 2015 at 9:52 PM, Thomas Burleson [email protected] wrote:
@ACDN https://github.com/ACDN - if you provide a Plunkr or CodePen that demonstrates this issue, we will reopen and address it.
— Reply to this email directly or view it on GitHub https://github.com/angular/material/issues/900#issuecomment-70039689.
@ACDN Here's the one I'm using: http://plnkr.co/edit/G0CCmRfi9CHxCPkwkiND?p=preview It's empty, but should have all the relevant includes.
Thanks that really helped me put this together quicker.
Here is the link to the plnkr that shows the issue: http://plnkr.co/edit/a9hQkClEce5RPEILZCc1?p=preview
In the xui-table I have placed a MD-CHECKBOX. You can see in the live preview that 2 are being displayed and if you check the console output you'll see the error that I posted earlier in this thread.
unable to reproduce.
Why was this closed as unable to reproduce when a plunkr was provided that shows the error?
I was wondering the same thing.
@ACDN - the plunkr you provided is simply too complicated to triage the issue.
So I created a simple CodePen test with a custom directive performing transclusion: http://codepen.io/ThomasBurleson/pen/MYvdNv. My own tests do not manifest the error: "Error: [ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found."
I am unable to reproduce the error in my tests. So I closed the issue.
Your demo uses the xui-table directive with a transclude:true option. But the template does not have a ng-transclude attribute directive. Hence the error.
@ThomasBurleson Your attempt to reproduce may have been too simplistic. I believe this problem is related to more complex custom transclusion scenarios. I will work on a sample to show the problem. I am also have similar issues with a number of md directives.
I have reproduced this error here on CodePen: http://codepen.io/anon/pen/myBYyX
This was the simplest example I could create to show the problem. While it may not seem realistic, it is representative of what I am seeing when I try to use material design directives inside of https://github.com/stevenh77/drop-ng and other 3rd party angular directives.
@ThomasBurleson @dpaquette To add to this, I narrowed it down a bit: http://plnkr.co/edit/rzVBw3eOejQCWkzhG75y?p=preview
Notice that when we receive the clone, the <md-checkbox> template has already been applied. I suspect that this is the issue.
@dpaquette - Thanks for contributing this more-easily introspected sample. In your CodePen it appears that you are incorrectly compiling the clone
var compiled = $compile(clone)(scope);
When you call a transclude function it returns a a jqLite/JQuery object that contains the compiled DOM, which is linked to the correct transclusion scope. When you call a transclusion function you can pass in a clone attach function. This function accepts two parameters, function(clone, scope) { ... }, where the clone is a fresh compiled copy of your transcluded content and the scope is the newly created transclusion scope, to which the clone is bound.
Since you are indeed using a clone attach function, If I do this:
var divForTransclusion = angular.element(element[0].querySelector('.contentGoesHere'));
divForTransclusion.append(clone);
then I do not detect an error. Am I missing a technical detail or issue?
Should this be already fixed? I'm having the same problem with version 1.0.8 (angular 1.5.6).