Angular 8 “ngIf” condition not working as expected

依然范特西╮ 提交于 2020-12-15 04:19:19

问题


I have 3 divs based on my condition. Those divs have to appear, actually it is working as expected for the first time

  1. div a
  2. div b
  3. div c

This is the condition I gave

<div class="pl-2 flex-grow-1 d-flex" *ngIf="getInfo!==3 && getInfo !== 5"></div>

<div class="pl-2 flex-grow-1 d-flex" *ngIf="getInfo==3"></div>

<div class="pl-2 flex-grow-1 d-flex" *ngIf="getInfo==5"></div>

Initially when I load first page first div is working as expected, no issue there. But when I got to second page the second div loaded and when again I come to first page, the second div is loading and not the first div.

Here is my TS code

   const getinfo = this.caService.info.subscribe((response) => {
      this.getInfo = +response 
   });

来源:https://stackoverflow.com/questions/64058914/angular-8-ngif-condition-not-working-as-expected

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!