内联if语句不工作角5

时间:2018-03-19 00:21:25

标签: javascript angular typescript

这是次要的,但我不知道我的生活会弄清楚发生了什么......所以

我有一个内联if语句,如此...

<button *ngIf="item?.fields?.assetType !== 'tool' || item?.fields?.assetType !== 'questions'">NEXT</button>

所以基本上功能是..如果返回的数据有assetType toolquestions没有显示按钮..现在行为可以正常工作返回的assetType tool按钮被隐藏但是当我获得assetType等于questions的数据时按钮仍会显示..

这里是正在返回的数据...正如您所看到的那样assetType等于questions所以..按钮应该被隐藏但是它不是

enter image description here

我确定这个问题很小我只是想弄清楚, 任何帮助将不胜感激!

1 个答案:

答案 0 :(得分:1)

对于assetType&#34;问题&#34;在上面的例子中,让我们来看看它:

item?.fields?.assetType!==&#39; tool&#39;的 TRUE

item?.fields?.assetType!==&#39;问题&#39;的 FALSE

语句将评估为 TRUE ,因为它是一个逻辑OR。