I've had to change your example slightly, as at my last check (using Angular 2.0.0-alpha.21), I was having issues retrieving properties from the same component class that was passed to the bootstrap method.
However, using a slighty modified example:
@Component({
selector: 'hero',
properties: {'name':'name'}
})
@View({
template:`<h1>Hero = {{_name}}</h1>`
})
class Hero {
_name: string;
constructor() {
};
set name(name){
this._name = name;
}
}
@Component({
selector: 'app',
})
@View({
template:
`
<div>
<hero name="iron man"></hero>
</div>
`,
directives: [Hero]
})
class Application {
constructor() { };
}
bootstrap(Application);
Then in your HTML:
<app>
<hero name="iron man" />
</app>
Note that from within your constructor, _name will be undefined. To have the property available in your construstor, you can inject it:
class Hero {
_name: string;
constructor(@Attribute('name') name:string) {
this._name = name;
};
}
This is mostly taken from my answer to this question