gpt4 book ai didi

angularjs - ng-if,不等于?

转载 作者:行者123 更新时间:2023-12-02 21:55:45 26 4
gpt4 key购买 nike

我有一个简单的 ng-reapt 来显示值列表。在某些输出上,我有几个 ng-if 来显示/隐藏 DIV。

HTML:

<div ng-repeat="details in myDataSet">

<p>{{ details.Name }}</p>
<p>{{ details.DOB }}</p>

<div ng-if="details.Payment[0].Status == '0'">
<p>No payment</p>
</div>

<div ng-if="details.Payment[0].Status == '1' || details.Payment[0].Status == '2'">
<p>Late</p>
</div>

<div ng-if="details.Payment[0].Status == '3' || details.Payment[0].Status == '4' || details.Payment[0].Status == '5'">
<p>Some payment made</p>
</div>

<div ng-if="details.Payment[0].Status == '6'">
<p>Late and further taken out</p>
</div>

<div ng-if="details.Payment[0].Status != '0' || details.Payment[0].Status != '1' || details.Payment[0].Status != '2' || details.Payment[0].Status != '3' || details.Payment[0].Status != '4' || details.Payment[0].Status != '5' || details.Payment[0].Status != '6'">
<p>Error</p>
</div>

<p>{{ details.Gender}}</p>

</div>

我的应用程序在尝试显示 != 部分时显示错误。

最佳答案

最好使用ng-switch

<div ng-switch on="details.Payment[0].Status">
<div ng-switch-when="1">
<!-- code to render a large video block-->
</div>
<div ng-switch-default>
<!-- code to render the regular video block -->
</div>
</div>

关于angularjs - ng-if,不等于?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24200729/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com