Skip to content

Angular RC.5 More than one component #10641

@kukjevov

Description

@kukjevov

I'm submitting a ... (check one with "x")

[x] bug report
[x] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
In angular rc.5 you can`t have multiple components with same selector, which was in previous versions working without any problem. In rc.5 you have single "context" in which are all directives stored for whole module. Previously if i added some component to @component directives array it was processed only in template of that component. Now it adds this component to some shared directives array for whole module.

By the way, this could be considered breaking change but it is not mentioned anywhere in changelog.

Expected/desired behavior

I would expected similar behaviour as for providers.
Components added to ngModule.declaration will be available in templates of all components. Components added to component.directives will override ngModule.declaration and will be available only in template of this component.

I know that probably solution would be use modules, but create module which will contain only 1 component is bad usage of ngModule. Since i have 6 components and 2 html files which are shared by 3 of them i would have to create 6 modules which is crazy.

Reproduction of the problem
Here is plunker showing problem https://plnkr.co/edit/u3ergwERz0vfsVmH0Fcb?p=preview Exactly same code would in rc.4 work without any problem. In rc.5 it is not working.

What is the motivation / use case for changing the behavior?

I need this because i have one html file for multiple components, which share same public interface but different "components" are injected into directives array. So single html can display different components.

This way i have to have 3 almost same html files (except one element).

Please tell us about your environment:

  • Angular version: 2.0.0-rc.5
  • Browser: [all]
  • Language: [TypeScript 1.8.10]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions