I'm having trouble getting ng-transclude to work within an ng-switch-default directive. Here's my code:
Directive:
.directive('field', ['$compile', function($complile) {
return {
restrict: 'E',
scope: {
ngModel: '=',
type: '@',
},
transclude: true,
templateUrl: 'partials/formField.html',
replace: true
};
}])
partials/formField.html
<div ng-switch on="type">
<input ng-switch-when="text" ng-model="$parent.ngModel" type="text">
<div ng-switch-default>
<div ng-transclude></div>
</div>
</div>
I call it like so...
<field type="other" label="My field">
test...
</field>
Which produces the error:
[ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found.
It works without a hitch, outside of the ng-switch directive, I'm at a loss on how to get this working though. Any suggestions?
EDIT:
Here's a live demo: http://plnkr.co/edit/3CEj5OY8uXMag75Xnliq?p=preview
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…