How to capture the text user enters in the ui:inputText
tried:
var searchText = document.querySelector('.searchKey').value;
and tried this as well...
var searchText = component.find("searchKey").get("v.value");
Component:
<aura:component >
<aura:attribute name="searchKey" type="String"/>
<div>
<div class="wrapper">
<ui:inputText aura:id="searchKey" class="searchKey" keyup="{!c.searchKeyChange}" value="{!v.searchKey}" placeholder="Search..."/>
</div>
</div>
</aura:component>
Controller:
({
searchKeyChange: function(component, event) {
var myEvent = $A.get("e.c:HouseSearchKeyChange");
var searchText = document.querySelector('.searchKey').value;
//var searchText = component.find("searchKey").get("v.value");
myEvent.setParams({"searchKey": document.querySelector(".searchKey").value });
myEvent.fire();
}
})
Something has gone wrong. Action failed: c$HouseSearchBar$controller$searchKeyChange [Cannot read property 'value' of null] Failing descriptor: {c$HouseSearchBar$controller$searchKeyChange}. Please try again.