gpt4 book ai didi

javascript - 不显示以前的语句 (ng-show)

转载 作者:行者123 更新时间:2023-11-28 04:57:31 25 4
gpt4 key购买 nike

当前一个文本发送给两位作者(或更多作者)时,我不想显示它。

<span ng-show="stepsdata.authors[0]">
{{authors[0].surname}} {{authors[1].surname}} ({{year}}
<span ng-hide="stepsdata.endPage">p. {{page}})</span>
<span ng-show="stepsdata.endPage">pp. {{stepsdata.startpage}} - {{stepsdata.lastpage}})</span>

</span>
<span ng-show="stepsdata.authors[1]"> Recent research
({{authors[0].surname}} and {{authors[1].surname}}, {{year}}) suggests that...
</span>
<span ng-show="stepsdata.authors[2]"> Recent research
({{authors[0].surname}}, {{authors[1].surname}} and {{authors[2].surname}}, {{year}}) suggests that...
</span>
<span ng-show="stepsdata.authors[3]"> Recent research
({{authors[0].surname}}, et al., ({{year}}) suggests that...
</span>

如果我只有一位作者,效果很好。

如果我有两位作者,它会显示 ng-show="stepsdata.authors[0]"和 ng-show="stepsdata.authors[1] 中的文本>”,但我只需要它来显示 ng-show="stepsdata.authors[1]"

中的文本

如果我有三位作者,它会显示 ng-show="stepsdata.authors[0]"和 ng-show="stepsdata.authors[1] 中的文本>”,然后来自 ng-show="stepsdata.authors[2]"但我只需要它来显示来自 ng-show="stepsdata.authors[2]< 的文本

其他情况也会发生这种情况。我该如何修复它?

最佳答案

使用数组的length属性:

<span ng-show="stepsdata.authors.length == 1">
{{authors[0].surname}} {{authors[1].surname}} ({{year}}
<span ng-hide="stepsdata.endPage">p. {{page}})</span>
<span ng-show="stepsdata.endPage">pp. {{stepsdata.startpage}} - {{stepsdata.lastpage}})</span>

</span>
<span ng-show="stepsdata.authors.length == 2"> Recent research
({{authors[0].surname}} and {{authors[1].surname}}, {{year}}) suggests that...
</span>
<span ng-show="stepsdata.authors.length == 3"> Recent research
({{authors[0].surname}}, {{authors[1].surname}} and {{authors[2].surname}}, {{year}}) suggests that...
</span>
<span ng-show="stepsdata.authors.length == 4"> Recent research
({{authors[0].surname}}, et al., ({{year}}) suggests that...
</span>

关于javascript - 不显示以前的语句 (ng-show),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42421400/

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