我是 angularjs 的初学者,我想对以下代码进行 if 语句。 伪代码:
if url.page exists then show this
{{url.page | decodeURIComponent}}
else show
{{url.path | decodeURIComponent}}
我怎样才能实现这个目标?
这是我的源代码:
<a href="{{vm.company_website}}{{url.path}}"
ng-if="url.path.indexOf('http') != 0"
target="_blank"
data-placement="bottom" data-toggle="tooltip" class="tip"
data-original-title="{{url.path}}" style="color:rgb(98, 98, 98);"
>
{{url.page | decodeURIComponent}}
</a>
最佳答案
{{url.page ? url.page : url.path | decodeURIComponent}}
应该做你想要的。
关于javascript - 如何在angularjs中创建一个简单的if then else?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55249727/