Skip to content

bug: PrivateComponentLoader can add decorators to a DynamicComponent #1062

@ajoslin

Description

@ajoslin

If I add a decorator to a component with PrivateComponentLoader, it errors.

But it tells me "You don't have a template", not that "You shouldn't be adding decorators dynamically".

When I do add a temlpate to my decorator, PrivateComponentLoader lets me add it:

@DynamicComponent({
  selector: 'dynamic-component',
  services: [PrivateComponentLoader, PrivateComponentLocation]
})
class MyDynamic {

  constructor(
    loader:PrivateComponentLoader, 
    location:PrivateComponentLocation
  ) {
    loader.load(TestRedDecorator, location);
  }
}

@Decorator({
  selector: '[red]'
})
@Template({
  inline: 'test'
})
export class TestRedDecorator {
  constructor(
    element:NgElement
  ) {
    element.domElement.style.background = 'red';
  }

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions