夏期劇*_*期劇場 5 if-statement angularjs ng-repeat angularjs-ng-repeat
我正在使用AngularJS v1.2.9.
在里面ng-repeat,我如何使用检查对象的值并根据条件执行操作?
在英语中,类似于:
if `X` is not null, then show `X`. Is it possible?
Run Code Online (Sandbox Code Playgroud)
这是我的ng-repeat骨架:
<li ng-repeat="r in results">
<div>{{ r.title }}</div>
<div>{{ r.location }}</div>
<!--
if ( r.date!=="null" ) {
<div>{{ r.date }}</div>
} else {
<div>Date not confirmed yet.</div>
}
-->
</li>
Run Code Online (Sandbox Code Playgroud)
我需要显示r.date它是否为空.如果它是null,那么我说别的.
请帮忙.谢谢大家.
<li ng-repeat="r in results">
<!-- If r.date contains a value, show it -->
<span ng-if="r.date">{{r.date}}</span>
<!-- If r.date does not contain a value show placeholder text -->
<span ng-if="!r.date">Date not confirmed yet.<span>
</li>
Run Code Online (Sandbox Code Playgroud)