ng-switch-default ディレクティブ内で ng-transclude を動作させるのに問題があります。これが私のコードです:
指令:
.directive('field', ['$compile', function($complile) {
return {
restrict: 'E',
scope: {
ngModel: '=',
type: '@',
},
transclude: true,
templateUrl: 'partials/formField.html',
replace: true
};
}])
パーシャル/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>
私はそう呼んでいます...
<field type="other" label="My field">
test...
</field>
エラーが発生します:
[ngTransclude:orphan] Illegal use of ngTransclude directive in the template! No parent directive that requires a transclusion found.
ng-switch ディレクティブの外では、問題なく動作しますが、これを機能させる方法に途方に暮れています。助言がありますか?
編集: ここにライブ デモがあります: http://plnkr.co/edit/3CEj5OY8uXMag75Xnliq?p=preview