Javascript 如何在将对象属性作为参数传递时使用连字符

Javascript 如何在将对象属性作为参数传递时使用连字符,javascript,angular,Javascript,Angular,我试图将对象属性作为参数传递。对象键包含连字符 对象 { "section-id": 1, ... } HTML <div *ngFor="let section of sections" (trackScrollLeave)="leave(section.section-id)"></div> 它正在控制台中输出NAN。如果使用camel casesectionId,它会起作用。代码以section.section-id(undefined-und

我试图将对象属性作为参数传递。对象键包含连字符

对象

{
    "section-id": 1,
    ...
}
HTML

<div *ngFor="let section of sections"
 (trackScrollLeave)="leave(section.section-id)"></div>

它正在控制台中输出
NAN
。如果使用camel case
sectionId
,它会起作用。

代码以section.section-id(undefined-undefined=NaN)的形式读取它


ngOnInit() {
    this.retrieveDataService.fetchData().subscribe(data=>{
            this.sections = data;
       });
  }

  leave(value) {
    console.log('Scroll left '+ value);
  }
}
<div *ngFor="let section of sections (trackScrollLeave)="leave(section['section-id'])"></div>