Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

transclude: true is probably a bad default for component helper #13566

Closed
@sarod

Description

@sarod

PR #12933 introduces the new component helper which is great.
However I found that using transclude:true as a default is probably a mistake as:

  • Most component don't need it. And it's find to enable it when you need it.
  • It doesn't play well with some native directive also requiring transclusion (namely ngSwitchWhen)

For instance when creating a simple component with

module.component('myComp', 
  {
    template:'<div></div>'
  }
);

And use it in a template like this:

<div ng-switch="x">
  <my-comp ng-switch-when="1"></my-comp>
  <div ng-switch-when="2"></div>
</div>

I get the following error:

[$compile:multidir] Multiple directives [ngSwitchWhen, myComp (module: myApp)] asking for transclusion on: <my-comp ng-switch-when="1">

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions