我正在开发一个 Lightning 应用程序,我在其中动态创建组件。截至目前,代码工作正常,没有错误。但我的问题是我们如何从中获得价值。
假设这是父控制器类,
clickMoreFilter: function(cmp, event, helper) {
$A.createComponent(
"c:AccountDynamicForm",
{
"aura:id": "findableAuraId",
"label": "Press Me",
"press": cmp.getReference("c.clickCreateExpense")
},
function(newButton, status, errorMessage){
//Add the new button to the body array
if (status === "SUCCESS") {
var body = cmp.get("v.body");
var newb = newButton.getElement('levels3');
console.log('checkCmp'+newb);
body.push(newButton);
cmp.set("v.body", body);
}
else if (status === "INCOMPLETE") {
alert("No response from server or client is offline.")
// Show offline error
}
else if (status === "ERROR") {
alert("Error: " + errorMessage);
// Show error message
}
}
);
},
这是我正在创建的动态组件:
<div aria-labelledby="newexpenseform">
<!-- CREATE NEW EXPENSE FORM -->
<br></br>
<form class="slds-form--inline">
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputSelect aura:id="accIndustry" class="slds-select"/>
</div>
</div>
<div class="slds-form-element slds-is-required">
<div class="slds-form-element__control">
<ui:inputSelect aura:id="levels3" class="slds-input">
<aura:iteration items="{!v.contactLevel1}" var="level">
<ui:inputSelectOption text="{!level}" label="{!level}"/>
</aura:iteration>
</ui:inputSelect>
</div>
</div>
<div class="slds-form-element">
<div class="slds-form-element__control" onfocusout="{!c.clickCreateExpense}">
<ui:inputText aura:id="inputValue"
class="slds-input"
labelClass="slds-form-element__label"
/>
</div>
</div>
</form>
<!-- / CREATE NEW EXPENSE FORM -->
</div>
现在如何从动态组件获取值到父组件?请帮我解决这个问题。提前致谢。