0
我正在開發一個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>
現在如何從dyn獲取值amic組件到父組件? 請幫我解決這個問題。提前致謝。