【发布时间】:2016-10-21 09:33:48
【问题描述】:
我有访问组件静态变量的循环。如果我使用“let person of people()”它不起作用。这里的persons方法返回多个人..得到“TypeError:self.context.persons不是函数”错误
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。 -
也许问题出在
let person of persons()中persons之后的大括号? -
是的,
get persons()不能使用persons()调用 -
是的..在没有 () 的情况下工作
标签: angular