因此使用* ngFor i显示了对象的name属性列表,这个对象也有一个名为isAvailable的属性我想设置isAvalable属性,当我点击它时,在true和false之间切换,并基于isAvalible下一个文本到li将显示是否可用
<p>Authors</p>
<ul>
<li *ngFor='let author of authors' (click)='onClick()'>
{{author.name}}
</li>
</ul>
答案 0 :(得分:0)
<p>Authors</p>
<ul>
<li *ngFor='let author of authors'>
<span [hidden]='author.isAvalible'>{{author.name}}</span>
<span (click)='onClick()'>author.isAvalible</span>
</li>
</ul>
onClick(value){
value=!value;
}
答案 1 :(得分:0)
据我所知你想要这个
<p>Authors</p>
<ul>
<li *ngFor='let author of authors'>
<span [hidden]='author.isAvalible'>{{author.name}}</span>
<span (click)='author.isAvalible = !author.isAvalible '>author.isAvalible</span>
</li>
</ul>