[英].get is not a function: When i am getting the value of the input to js controller i am facing the error
I am using input tag inside the iteration to the table.我在表的迭代中使用输入标签。 component.find and get are not working in js controller.
component.find 和 get 在 js controller 中不起作用。 Getting the error: This page has an error.
收到错误:此页面有错误。 You might just need to refresh it.
您可能只需要刷新它。 Action failed:nPrice.get is not a function] Failing descriptor: {c:SP_TCOSandboxLicense$controller$CalculatePrice}
操作失败:nPrice.get 不是函数] 失败描述符:{c:SP_TCOSandboxLicense$controller$CalculatePrice}
Component:零件:
<aura:attribute name="negotiatePrice" type="Integer" />
<table class="slds-table slds-table--bordered slds-table--cell-buffer">
<tbody>
<aura:iteration items="{!v.userList}" var="con" aura:id="usrLst">
<tr>
<th scope="row">
<div class="slds-truncate" title="{!con.Name}">
{!con.Name}
</div>
</th>
<th scope="row">
<div aura:id="usrLic" class="slds-truncate" title="{!con.TotalLicenses}">{!con.TotalLicenses}</div>
</th>
<th scope="row">
<aura:iteration items="{!v.costList}" var="cst">
<aura:if isTrue="{!con.Name == cst.Name}">
<div class="slds-truncate" title="{!cst.License_Price_Per_Month__c}">{!cst.License_Price_Per_Month__c}</div>
</aura:if>
</aura:iteration>
</th>
<th scope="row" >
<div class="slds-truncate">
<input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField" value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" />
</div>
</th>
</tr>
</aura:iteration>
</tbody>
</table>
Controller: Controller:
CalculatePrice : function(component, event, helper) {
alert('Calculate');
var nPrice = component.find("myAtt");
var negotiatePrice = nPrice.get("v.value");
alert('negotiatePrice'+negotiatePrice);
}
You can basically use the event
directly, it will be more efficient: event.target.value
基本上可以直接使用
event
,效率会更高: event.target.value
Also if I remember correctly from the time I was writing Aura Component, because you provided value={.v.negotiatePrice}
you can do component.get('v.negotiatePrice')
in your controller to get the value.另外,如果我在编写 Aura 组件时没记错的话,因为您提供了
value={.v.negotiatePrice}
,您可以在 controller 中执行component.get('v.negotiatePrice')
来获取值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.