0

我有銀行自帶的分期付款清單,我想重複銀行支持分期付款或不在付款頁面上的列表。列表必須是數到9,從2ng-if與ng-if表達式的多重ng-

開始,這是JSON(僅包括第一銀行)

[{ 
     "Installments": [{ 
     "InstallmentId": 9, 
     "InstCount": 2, 
     "InstRate": 0, 
     "BankId": 1, 
     "Info": false 
     }, { 
     "InstallmentId": 10, 
     "InstCount": 3, 
     "InstRate": 0, 
     "BankId": 1, 
     "Info": false 
     }, { 
     "InstallmentId": 11, 
     "InstCount": 4, 
     "InstRate": 7.30, 
     "BankId": 1, 
     "Info": false 
     }, { 
     "InstallmentId": 12, 
     "InstCount": 5, 
     "InstRate": 0, 
     "BankId": 1, 
     "Info": false 
     }, { 
     "InstallmentId": 13, 
     "InstCount": 7, 
     "InstRate": 4.50, 
     "BankId": 1, 
     "Info": false 
     }, { 
     "InstallmentId": 14, 
     "InstCount": 9, 
     "InstRate": 11.28, 
     "BankId": 1, 
     "Info": false 
     }], 
     "BankId": 1, 
     "BankName": "Garanti", 
     "IsInstallments": false, 
     "BankLogo": "img/bank/cards-01.png" 
    }, { 
     "Installments": [...], 
     "BankId": 2, 
     "BankName": "Advantage", 
     "IsInstallments": false, 
     "BankLogo": "img/bank/cards-05.png" 
    }, { 
     "Installments": [...], 
     "BankId": 3, 
     "BankName": "Finansbank", 
     "IsInstallments": false, 
     "BankLogo": "img/bank/cards-03.png" 
    }] 

這是HTML標記:

<div id="installments" 
    class="{{bankValue !== '' ? 'inactive' : '' }}"> 
     <div class="row m0 row-paddless"> 
     <div class="col-xs-4 col-sm-2" 
     ng-repeat="bank in json" > 
      <section data-bank-id="{{bank.BankId}}" 
      class="bank {{bankValue == bank.BankId ? 'active' : 'inactive' }}"> 
      <div style="background-image: url('{{bank.BankLogo}}');" class="img-holder"></div> 
      <ul> 

       <li ng-repeat-start="i in [2,3,4,5,6,7,8,9]" 
       ng-if="bank.Installments[i-2].InstCount !== i || bank.Installments[i-2].InstCount == undefined"> 
       <p>{{i}} TAKSİT</p> 
       <p>disabled</p> 
       <p><small>disabled</small></p> 
       </li> 
       <li ng-repeat-end="i in [2,3,4,5,6,7,8,9]" 
       ng-click="clickLi(ins, bank)" 
       ng-if="bank.Installments[i-2].InstCount == i" class="{{installmentValue == bank.Installments[i-2].InstCount ? 'active' : '' }} {{bank.Installments[i-2].InstRate == 0 ? 'special' : '' }}"> 
       <p>{{bank.Installments[i-2].InstCount}} TAKSİT</p> 
       <p><span itemprop="price" class="price-value" ng-init="newPrice = price + (price * bank.Installments[i-2].InstRate/100)"> {{ newPrice | number:2 }} TL</span></p> 
       <p ng-init="installedPrice = ((price + (price * bank.Installments[i-2].InstRate/100))/bank.Installments[i-2].InstCount)"><span><small> {{ installedPrice | number:2 }} TL X {{bank.Installments[i-2].InstCount}} ay</small></span></p> 
       </li> 
      </ul> 
      </section><!-- "bank" --> 
     </div><!-- "col-xs-4 col-sm-2" --> 
     </div><!-- "row" --> 
    </div><!-- installments --> 

這是我所得到的(截圖): http://aslanbakan.com/down/bank-error.PNG

這是我想才達到(截圖): http://aslanbakan.com/down/bank-achive.PNG

我不知道我犯了什麼錯誤。

+1

的鏈接,截圖不好。另外,如果你可以提供一個最小的工作例子(JSFiddle,JS Bin等),它將會非常有幫助。 – alesc

+0

修復了ss。並添加了筆.. [codepen鏈接](http://codepen.io/Aslanbakan/pen/PqKGQY) – eomerx

回答

0

據我所知,你只想顯示那些有分期付款的銀行。

您檢查

bank.Installments[i-2].InstCount == undefined 

但你需要檢查的typeof屬性等於不確定的,就像這樣:

typeof bank.Installments[i-1].InstCount === 'undefined' 

更新筆你提供:http://codepen.io/anon/pen/dozpBE

+0

不,我實際上想顯示所有項目,無論分期存在與否。 如果安裝不存在,我想在該項目上顯示禁用的文本。就像'想要實現'截圖一樣。 – eomerx

+0

你應該使用ng-class而不是ng-if在這種情況下。 – YOU

+0

我仍然不明白是什麼問題...看到這個筆:http://codepen.io/anon/pen/eNEBpK –