2017-04-06 53 views
0

我有一個Lightning組件,用於偵聽已更新的帳戶事件並檢索關聯的聯繫人和用戶。然後,它會顯示聯繫人和用戶總數的聯繫人,並創建一個包含重複Tiles的SLDS卡。光環:如果不評估和光環:不顯示迭代

它工作正常,直到我更改標題說'加載',而加載聯繫人。我添加了兩個新的屬性(一個用於保存加載狀態,一個用於保存聯繫人和用戶的總數)並添加了更新這些屬性的邏輯。不知何故,這打破了它,我無法弄清楚它是如何破的。

根據控制檯和調試日誌,一切都很好。正在從Apex控制器正確檢索聯繫人和用戶,並將這些值寫入屬性。然而,沒有更新。

ContactTable.cmp

<header class="slds-media slds-media--center slds-has-flexi-truncate"> 
 
    <div class="slds-media__body"> 
 
     <h2> 
 
      <span class="slds-text-heading--large"> 
 
       <aura:if istrue="{!v.accountName}"> 
 
        Contacts For {!v.accountName}: {!v.contactsLoadingStatus} 
 
        <aura:set attribute="else"> 
 
         Contacts: - Please Select a Clinic - 
 
        </aura:set> 
 
       </aura:if> 
 
      </span> 
 
     </h2> 
 
    </div> 
 
</header> 
 

 
......... 
 
(Contacts Tile Iterator) 
 
......... 
 

 
<aura:if istrue="{!v.contacts.length > 0}"> 
 
    <h2 style="padding-left: 1.5rem;"><span class="slds-text-heading--medium">Contacts</span></h2> 
 
    <div class="slds-card__body--inner slds-grid slds-wrap" style="margin-bottom: 30px; height: 20rem;  overflow: auto; border: 1px solid rgba(128, 128, 128, 0.32); border-radius: 10px;"> 
 
     <aura:iteration items="{!v.contacts}" var="singleContact"> 
 
      <c:ContactTableContactCard singlecontact="{!singleContact}" /> 
 
     </aura:iteration> 
 
    </div> 
 
</aura:if>

ContactTableController.js

handleUpdateAccountEvent: function(component, event, helper){ \t \t 
 
    helper.updateAccount(component, event); 
 
    component.set('v.selectedContacts', null); 
 
    component.set('v.total', 0); 
 

 
    console.log('Account ID: ' + component.get('v.accountID')); 
 
    console.log('Account Name: ' + component.get('v.accountName')); 
 

 
    if(component.get('v.accountID')){ 
 
    console.log('Grabbing contacts and team members'); 
 
    component.set('v.contactsLoadingStatus', 'Loading...'); 
 
    helper.setContacts(component, helper); 
 
    helper.setTeamMembers(component, helper); \t \t 
 
    } 
 
    else{ 
 
    component.set('v.contacts', null); 
 
    component.set('v.teamMembers', null); 
 
    } 
 
},

ContactTableHelper.js

setContacts: function (component, helper) { 
 
    var action = component.get("c.getContacts"); 
 
    var accountID = component.get("v.accountID"); 
 
    action.setParams({'accountId':accountID}); 
 

 
    action.setCallback(this, function(response){ 
 
    if(component.isValid()){ 
 
     var state = response.getState(); 
 
     if(state === 'SUCCESS'){ 
 
     var contacts = response.getReturnValue(); 
 
     component.set("v.contacts", contacts); 
 

 
     var total = component.get("v.total"); 
 
     total += contacts.length; 
 
     component.set("v.total", total); 
 

 
     component.set("v.contactsLoadingStatus", total + " Records"); 
 

 
     contacts = component.get('v.contacts'); 
 
     console.log('Grabbing contacts.... Done'); 
 
     console.log('contacts:'); 
 
     console.log(contacts); 
 

 
     } 
 
     else{ 
 
     console.log('There was an issue in retrieving the contacts.'); 
 
     console.log(state); 
 
     if(state === 'ERROR'){ 
 
      var errors = response.getError; 
 
      for(var i = 0; i < errors.length; i++){ 
 
      console.log(errors[i].message); 
 
      } 
 
     } 
 
     } 
 
    } 
 
    }); 
 

 
    $A.enqueueAction(action); 
 
    console.log('Grabbing contacts....'); 
 
}, 
 

 
updateAccount: function(component, event){ 
 
    var accountID = event.getParam("accountID"); 
 
    component.set("v.accountID", accountID); 
 

 
    var accountName = event.getParam("accountName"); 
 
    component.set("v.accountName", accountName); 
 
    console.log('finished updateAccount'); 
 
},

我離開了setTeamMembers,因爲它是一樣的,或多或少,作爲setContacts。

相關控制檯日誌:

完成updateAccount

帳戶ID:001F0000013YX5DIAW

帳戶名稱:〜名〜。

拼搶接觸和團隊成員

拼搶接觸....

拼搶團隊成員....

拼搶接觸....完成

聯繫人:

[對象,對象,對象]

G rabbing團隊成員....完成

teamMembers:

[對象,對象,對象,對象,目標,對象]

回答

0

我想通了。我用我的IDE的代碼格式化從而改變

<aura:if isTrue="">

<aura:if istrue="">

所以,如果別人運行到這個問題,請檢查您的拼寫。