Angular 2 input parameters on root directive [duplicate]
Solution 1:
I think you could still use:
class App {
constructor(elm: ElementRef) {
this.something = elm.nativeElement.getAttribute('something');
}
}
Solution 2:
This Tobias Bosch's comment has answer on your question:
The reason why this is not working is that your index.html in which you place the
<app something="Test"></app>
is not an angular component. Because of this, Angular won't compile this element. And Angular does not read attribute values during runtime, only during compile time, as otherwise we would get a performance hit.
So, at this moment you can't use input parameters on root element.