如何在angular2模板中访问带连字符的属性时使用elvis运算符
http://plnkr.co/edit/z3Wqn7EScgxcAhrFJWjv?p=preview
//our root app component
import {Component} from 'angular2/core'
@Component({
selector: 'my-app',
providers: [],
template: `
<div>
<h2>Hello {{name}}</h2>
{{asyncObj1?.theprop}}
{{asyncObj2?['the-prop']}} <!-- this throws error -->
</div>
`,
directives: []
})
export class App {
constructor() {
setTimeout(function(){
this.asyncObj1 = {
'theprop': 'value'
}
this.asyncObj2 = {
'the-prop': 'async value'
}
}, 2000)
}
}