Skip to content

Instantly share code, notes, and snippets.

@anilsomasundaran
Created April 21, 2018 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anilsomasundaran/76f84dc0a0503acbc22be7564a82001d to your computer and use it in GitHub Desktop.
Save anilsomasundaran/76f84dc0a0503acbc22be7564a82001d to your computer and use it in GitHub Desktop.
<aura:component extends="c:AbstractBase" controller="TestApexController">
<aura:attribute name="message" type="String" default=""/>
<aura:attribute name="serverMessage" type="String" default="" description="server message assigns to this"/>
<aura:attribute name="showError" type="Boolean" default="false" />
<aura:attribute name="showServerError" type="Boolean" default="false" />
<ui:inputText label="Message" value="{!v.message}" />
<lightning:input type="checkbox" label="Show Error" name="showErrorCheck" checked="{!v.showError}"/>
<lightning:button variant="brand" label="Send Message" onclick="{! c.sendMessage }" />
<br/><br/><br/>
<aura:if isTrue="{!v.showServerError}">
Server Message : {!v.serverMessage}
<aura:set attribute="else">
Server Message : {!v.serverMessage}
</aura:set>
</aura:if>
</aura:component>
({
sendMessage : function(component, event, helper) {
helper.sendMessage(component,helper);
}
})
({
sendMessage : function (component,helper) {
var message = component.get("v.message");
var showError = component.get("v.showError");
var param = {"message":message,"showError":showError};
helper.runServerMethod(component,"c.callApexControllerMethod",function(response){
component.set("v.serverMessage",response.getReturnValue());
}, function(errors) {
component.set("v.showServerError",true);
component.set("v.serverMessage",errors[0].message);
},param);
console.log(message,showError);
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment