0

Suppose I have a component

@Component({
  selector: 'mycomponent',
  template: '...'
})
class MyComponent {
}

Normally it renders template under <mycomponnent></mycomponent>, is there a way I could let this component render but by replacing the selector? I saw https://angular.io/docs/ts/latest/api/core/index/ComponentMetadata-class.html but not sure which configuration could lead to such behavior.

0

1 Answer 1

0

This is (at least currently) not supported.

What you can do instead is using an attribute selector like

@Component({
  selector: '[mycomponent]',
  template: '...'
})
class MyComponent {
}

then it can be used with any tag like

<li mycomponent></li> 
Sign up to request clarification or add additional context in comments.

2 Comments

You mean if I use an attribute selector <li mycomponent></li> will be replaced by what's in template? I wonder why would selectors have different behaviors when it comes t rendering.
There is nothing being replaced but you (or the user of your component) can freely choose the element name that should become your component.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.