Update
The reason why this is not working is that your index.html in which
you place the 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.
https://github.com/angular/angular/issues/1858#issuecomment-151326461
This will do what you want:
index.html
<app myname="some_name"></app>
Root component
export class CupBuyComponent {
@Input() myname: String;
constructor(elm: ElementRef){
this.myname = elm.nativeElement.getAttribute('myname');
}
}
Also if you want pass data as object you can take a look at this question
- Passing server parameters to ngModule after RC5 upgrade
Original
If you want to pass data as text then it should be
<app [myname]="'some_name'"></app>
or
<app myname="some_name"></app>