2017-04-06 54 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="">

所以,如果别人运行到这个问题,请检查您的拼写。