1
구성 변수 정적 변수에 액세스하는 루프가 있습니다. "person person()"을 사용하면 작동하지 않습니다. 여기에 사람의 방법은 점점 .. 여러 사람을 반환 : 오류 "형식 오류 함수가 아닌 self.context.persons을"angular2의 ngFor에서 static 변수에 액세스하는 방법
static persons: Array<PersonDirective> = [];
get persons(){
return PersonInvolvedComponent.persons;
}
HTML은
<person-directive *ngFor="let person of persons(); #idx = index" (remove) = "removePerson(idx)">
</person-directive>
이것이 작동하지 않는 이유는 알 수 없습니다. '#idx = index'는 유효하지 않습니다. 그것은'let idx = index'이어야합니다. –
아마도 'person of let persons()'에서'persons '뒤에 오는 중괄호가 문제일까요? – rinukkusu
그럴 수 있습니다. 'persons()'를 사용하면'persons() '를 사용하여 호출 할 수 없습니다 –