반응형
Angular를 사용하여 데이터 속성을 작성하는 방법
뭔가 빠진 것 같아요. data
attribute
내에서 를 사용하려고 template
하면 다음과 같이하십시오.
<ol class="viewer-nav">
<li *ngFor="#section of sections" data-value="{{ section.value }}">
{{ section.text }}
</li>
</ol>
Angular 2
충돌 :
예외 : 템플릿 구문 분석 오류 : 'sectionvalue'에 알려진 기본 속성이 아니기 때문에 'sectionvalue'에 바인딩 할 수 없습니다 ( "
] data-sectionvalue = "{{section.value}}"> {{section.text}}
구문에 문제가있는 것 같습니다. 도와주세요.
대신 속성 바인딩 구문을 사용하십시오.
<ol class="viewer-nav"><li *ngFor="let section of sections"
[attr.data-sectionvalue]="section.value">{{ section.text }}</li>
</ol>
또는
<ol class="viewer-nav"><li *ngFor="let section of sections"
attr.data-sectionvalue="{{section.value}}">{{ section.text }}</li>
</ol>
또한보십시오 :
액세스에 대해
<ol class="viewer-nav">
<li *ngFor="let section of sections"
[attr.data-sectionvalue]="section.value"
(click)="get_data($event)">
{{ section.text }}
</li>
</ol>
과
get_data(event) {
console.log(event.target.dataset.sectionvalue)
}
참고 URL : https://stackoverflow.com/questions/34542619/how-can-i-write-data-attributes-using-angular
반응형
'Programing' 카테고리의 다른 글
Mac OS X에서 gradle 설치 / 업그레이드 (0) | 2020.05.14 |
---|---|
_csv. 오류 : 필드 제한보다 큰 필드 (131072) (0) | 2020.05.14 |
Linux에서 포트가 열려 있는지 효율적으로 테스트합니까? (0) | 2020.05.14 |
Sublime Text 2의 각 선택 항목에 선택 항목 당 한 번씩 숫자를 추가하십시오. (0) | 2020.05.14 |
Xcode 9에서 열린 여러 시뮬레이터에서 단일 시뮬레이터를 종료하거나 닫는 방법은 무엇입니까? (0) | 2020.05.14 |