Hide/show individual items inside ngFor

后端 未结 6 645
独厮守ぢ
独厮守ぢ 2020-11-28 08:31

I need to show / hide part of component. Here is Angular2 example.

  • 6条回答
    •  刺人心
      刺人心 (楼主)
      2020-11-28 09:27

      In component class, declare hideme variable (typescript):

      export class MyPage{
         hideme = {};
         constructor(){
             this.hideme = {}; // init is required
         }
         ...
      

      Show/hide control in template:

    • show/hide
      The content will show/hide
    • Notes: hideme not required init because hideme[item.id] is undefined thus !hideme[item.id] will true.

    提交回复
    热议问题