You need to sign in to do that
Don't have an account?
prasanth puvvada 4
problem with simple if statement in aura component.
I want to display the todays date . so i created this component and insetedinto the aura:application. at loading this page i am getting this error.
Error during init : Unable to find 'checkWeekday' on 'compound://c.MOTD1'.
Error during init : Unable to find 'checkWeekday' on 'compound://c.MOTD1'.
<aura:component implements="force:appHostable"> <aura:attribute name="{!v.dayofweek}" type="string" default=""/> <aura:handler name="init" value="{!this}" action="{!c.callday}" /> <aura:if isTrue="{!v.dayofweek == 'sunday' }" > <b>This is {!v.dayofweek} </b> </aura:if> <aura:if isTrue="{!v.dayofweek == 'monday'}" > <b>This is {!v.dayofweek} </b> </aura:if> <aura:if isTrue="{!v.dayofweek == 'tuesday' }"> <b>This is {!.dayofweek} </b> </aura:if> <aura:if isTrue="{!v.dayofweek == 'weds' }" > <b> This is {!v.dayofweek} </b> </aura:if> </aura:component>
({ checkday : function(component) { var d= new Date(); var weekday=new Array(7); weekday[0]= "sunday"; weekday[1]="monday"; weekday[2]="tuesday"; weekday[3]="wednesday"; var n=weekday[d.getday()]; component.set("v.dayofweek",n); } })
Krishna Sambaraju
In your component the handler "init" is calling an action "c.callday", but the function you created is "checkday". Change the function to "callday" and check it.