You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Repository navigation
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
ng-transclude doesn't work inside ng-switch-default #4969
Hi,
the problem is that ng-switch is using a transclude as well, which leads to the error.
In your case, you should create a new directive that uses the right $transclude function. For this to work, store the $transclude in the controller of your parent directive (in your case field), and create a new directive that references that controller and uses its $transclude function.
@vojtajina Do you mean we should have a general solution for this, e.g. allow ng-transclude directive to define the transclude it should use, or only make ng-transclude work nicely with directives that are part of angular core (like ng-switch, ng-if, ng-repeat, ...)?
@chiptus, it seems pretty fixed to me (up until v1.5.5): http://plnkr.co/edit/M5vcubGIDkKuCeDqD4cc?p=preview
If you think you have found a bug, please open a new issue, providing the necessary details (e.g. expected vs actual behavior, a demo, steps to reproduce etc). Thx !
Activity
btford commentedon Jan 4, 2014
Confirmed this is an issue on 1.2.7 as well.
dberringer commentedon Jan 20, 2014
+1
ofpiyush commentedon Feb 10, 2014
+1
marbetschar commentedon Feb 21, 2014
+1 from here
3 remaining items
tbosch commentedon Mar 28, 2014
Hi,
the problem is that
ng-switchis using a transclude as well, which leads to the error.In your case, you should create a new directive that uses the right
$transcludefunction. For this to work, store the$transcludein the controller of your parent directive (in your casefield), and create a new directive that references that controller and uses its$transcludefunction.In your example:
In the html, you then just use
<div field-transclude>instead of<div ng-transclude>.Here is an updated plunker: http://plnkr.co/edit/au6pxVpGZz3vWTUcTCFT?p=preview
Closing this as not a bug. Sorry for the late answer and please comment if you think I understood you incorrectly.
vojtajina commentedon May 14, 2014
@tbosch I think this is a bug. What you described is a workaround.
tbosch commentedon May 14, 2014
@vojtajina Do you mean we should have a general solution for this, e.g. allow
ng-transcludedirective to define the transclude it should use, or only makeng-transcludework nicely with directives that are part of angular core (likeng-switch,ng-if,ng-repeat, ...)?petebacondarwin commentedon May 15, 2014
This is fixed by #7387 : http://plnkr.co/edit/BqGa4FU8Int2NkXlCRL1?p=preview
axelson commentedon Apr 22, 2015
Note: #7387 was never merged.
chiptus commentedon May 31, 2016
can we reopen this? it's not fixed
gkalpak commentedon May 31, 2016
@chiptus, it seems pretty fixed to me (up until v1.5.5): http://plnkr.co/edit/M5vcubGIDkKuCeDqD4cc?p=preview
If you think you have found a bug, please open a new issue, providing the necessary details (e.g. expected vs actual behavior, a demo, steps to reproduce etc). Thx !