Hi iam getting value from event and is being handled by handlePassedAccAdd method. I want to display value in {!v.contact.MailingCity}" which is getting alert, but it is not getting displayed in component. I don't know where i am going wrong.
CMP
<aura:attribute name="contact" type="Contact" default="{ 'sobjectType': 'Contact' ,
'First Name': '',
'LastName': '',
'Phone':'',
'Email':'',
'MailingCountryCode':'US',
'MailingStreet':'',
'MailingCity':'',
'MailingStateCode':'',
'MailingPostalCode':''
}" />
<aura:attribute name="acc" type="Account" default="{ 'sobjectType': 'Account' ,
'Name':'',
'Phone':'',
'Company_Email__c':'',
'BillingStreet':'',
'BillingCountryCode':'',
'BillingCity':'',
'BillingStateCode':'',
'BillingPostalCode':'' }" />
<div class="slds-grid slds-grid slds-wrap slds-grid--pull-padded">
<div class="slds-large-size--2-of-5 slds-medium-size--5-of-12 slds-small-size--1-of-1" aura:id="dMCity">
<div class="slds-m-horizontal-large">
<div Style="margin-right:50px; margin-left:50px; margin-top:10px">
<label for="MCity">Mailing City</label>
<force:inputField aura:id="MCity" value="{!v.contact.MailingCity}" />
</div>
</div>
</div>
JS
handlePassedAccAdd : function(component, event, helper) {
var accInfoAddr = event.getParam("acc");
alert('^^^^^^^^^^acc^^^^^^^^^^' + JSON.stringify(accInfoAddr));
var ContInfo = component.get("v.contact");
component.get("v.acc");
component.set("v.acc", accInfoAddr);
var AccInfo1 = component.get("v.acc.BillingCity");
// alert( component.get("v.acc.BillingCity"));
ContInfo.BillingCity = component.get("v.acc.BillingCity");
component.set("v.contact.MailingCity", ContInfo.BillingCity);
var AccInfo2 = component.get("v.acc.BillingStreet");
ContInfo.BillingStreet = component.get("v.acc.BillingStreet");
component.set("v.contact.MailingStreet", ContInfo.BillingStreet);
var AccInfo3 = component.get("v.acc.BillingCountryCode");
ContInfo.BillingCountryCode = component.get("v.acc.BillingCountryCode");
component.set("v.contact.MailingCountryCode", ContInfo.BillingCountryCode);
var AccInfo4 = component.get("v.acc.BillingStateCode");
ContInfo.BillingStateCode = component.get("v.acc.BillingStateCode");
component.set("v.contact.MailingStateCode", ContInfo.BillingStateCode);
var AccInfo5 = component.get("v.acc.BillingPostalCode");
console.log('v.acc.BillingPostalCode' + component.get("v.acc.BillingPostalCode"));
ContInfo.BillingPostalCode = component.get("v.acc.BillingPostalCode");
component.set("v.contact.MailingPostalCode", ContInfo.BillingPostalCode);
},
Object
and set the same to thecontact
attribute;var contactData = {field1: value1, ... fieldN: valueN};
and then finally do the assignmentcomponent.set("v.contact", contactData);
"First Name"
is not possible). Second, ifaccAdd
is an account attribute - you cannot usecomponent.get("v.accAdd.BillingStreet") - you should use
component.get("v.accAdd")` and then use the field that you want -AccAddInfo2.BillingStreet
. Then third - please share more code so we could understand your problem...