這是一個簡單的例子:AngularJS - NG-如果檢查字符串值爲空
<a ng-if="item.photo == ''" href="#/details/{{item.id}}"><img src="/img.jpg" class="img-responsive"></a>
<a ng-if="item.photo != ''" href="#/details/{{item.id}}"><img ng-src="/{{item.photo}}" class="img-responsive"></a>
我看到它總是產生,即使爲空值的item.photo != ''
條件。爲什麼?
你的意思是它仍然有'NG-IF = 「item.photo!= ''」'屬性? – dfsq 2014-12-09 13:28:32
不相關,但是這只是爲了更改圖像源而看起來像很多重複。 – 2014-12-09 13:32:44
也許'item.photo'不是一個空字符串,而是'null'或'undefined'? – 2014-12-09 13:35:08