Consider the following plunker
import {Component} from 'angular2/core'
@Component({
selector: 'my-app',
template: `
<div *ngFor="#option of myHashMap">
<input type="radio" name="myRadio" id="{{generateId(option['id'])}}">
<label for="{{generateId(option['id'])}}">
{{option['name']}}
</label>
</div>
`
})
export class App {
myHashMap = [{'name': 'myName1', 'id': 'id1'},{'name': 'myName2', 'id': 'id2'}]
generateId(key) {
return "myKey" + key;
}
}
I am trying to bind a string to id
in input
and the same string to for
in label
. However I run into
Can't bind to 'for' since it isn't a known native property ("hMap">
<input type="radio" name="myRadio" id="
Is there an angular2 idiomatic way of achieving this?