0

i am trying to add two input fields , one output field and one button in lightning component and then upon adding this component to app builder , i am getting this error.

Code is as follows:

Component:

<aura:component controller="JN_TimeZoneIssue" implements="flexipage:availableForAllPageTypes" >

  <ui:inputText label="Enter the time " aura:id="name" value="{!v.dateAndTime}"/>
   <ui:inputText label="Enter the time zone " aura:id="name1" value="{!v.timeZone}" />
   <ui:outputText aura:id="nameOutput" value="{!v.outputTime}"/>
    <ui:button aura:id="outputButton" label="Convert Time" press="{!c.calculateTime}"/>

</aura:component>

Component controller:

({
    getInput : function(component, event, helper) {
             //: function(cmp, event) {
      var selectedTime = component.find("name").get("v.value");
      var selectedTimeZone = component.find("name1").get("v.value");
     // var outName = cmp.find("nameOutput");        
      var action = component.get("c.calculateTime");
         action.setParams({
            "selectedTime": selectedTime
             "selectedTimeZone" :selectedTimeZone 

        });
        action.setCallback(this, function(data) {
        component.set("v.outputTime", data.getReturnValue());
        });
        $A.enqueueAction(action);

          }

})

Apex COntroller:

public class JN_TimeZoneIssue {

   @AuraEnabled public String timeZone{get;set;}
   @AuraEnabled public Datetime dateAndTime{get;set;}
 //  @AuraEnabled public boolean showOutput{get;set;}
   @AuraEnabled public String updatedTime{get;set;}

@AuraEnabled    
    public static String calculateTime(String selectedTimeZone, Datetime selectedTime){
        String newTime =   selectedTime.format('MM/dd/yyyy hh:mm:ss a',+selectedTimeZone);
        return newTime;
    }



}
  • I don't see an error. Could you please edit your question? – sfdcfox Aug 9 '17 at 19:24
0

Your component is missing a lot of information

1) None of the attributes are declared in your component.

2) Rewire you button to call getInput method missing in client side controller.

3) This is the actual reason why you are seeing the error"Cannot read property 'apply' of undefined" , you are missing a comma between the 2 parameters in your setparams:

 action.setParams({
            "selectedTime": selectedTime,
             "selectedTimeZone" :selectedTimeZone 

        }); 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.