You need to sign in to do that
Don't have an account?
Mohith Sundar
Hello Playground lightning trailhead
Hi All ,
Below is the code snippet code which is highlighted in bold is not executing, i logged into to iphone then checked , code is not returning true for {!v.messages[0] can someone help pls , what wrong going through
<aura:component >
<aura:attribute name="messages" type="List"
default="['you look nice today.',
'Great whether we are having.',
'How are you?']"/>
<h1> Hello Playground</h1>
<p> Silly fun with attributes and expressions</p>
<br></br>
<h2> List Items</h2>
<br></br>
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
<p> <c:hellomessage message="{!v.messages[2]}"/> </p>
<br></br>
<h2> List iteration </h2>
<br> </br>
<aura:iteration items="{!v.messages}" var="msg">
<p> <c:hellomessage message="{!msg}"/> </p>
</aura:iteration>
<br></br>
<h2> conditional Expressions and Global value providers</h2>
<br></br>
<aura:if isTrue="{!$Browser.isIPhone}">
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<aura:set attribute="else">
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
</aura:set>
</aura:if>
</aura:component>
Below is the code snippet code which is highlighted in bold is not executing, i logged into to iphone then checked , code is not returning true for {!v.messages[0] can someone help pls , what wrong going through
<aura:component >
<aura:attribute name="messages" type="List"
default="['you look nice today.',
'Great whether we are having.',
'How are you?']"/>
<h1> Hello Playground</h1>
<p> Silly fun with attributes and expressions</p>
<br></br>
<h2> List Items</h2>
<br></br>
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
<p> <c:hellomessage message="{!v.messages[2]}"/> </p>
<br></br>
<h2> List iteration </h2>
<br> </br>
<aura:iteration items="{!v.messages}" var="msg">
<p> <c:hellomessage message="{!msg}"/> </p>
</aura:iteration>
<br></br>
<h2> conditional Expressions and Global value providers</h2>
<br></br>
<aura:if isTrue="{!$Browser.isIPhone}">
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<aura:set attribute="else">
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
</aura:set>
</aura:if>
</aura:component>
Hello You can check it on controller by var isIphone=$A.get("$Browser.isIPhone") and create a attribute assign value to attribute, use the attribute instead of direct in component.
<aura:attribute name="isIphone" type="boolean" >
<aura:if isTrue="{!$Browser.isIPhone}">
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<aura:set attribute="else">
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
</aura:set>
</aura:if>
var isIphone=$A.get("$Browser.isIPhone")
component.set("v.isIphone", isIphone);
Maybe it works
for the below code should i create a controller how do i use it , could you please guide me
var isIphone=$A.get("$Browser.isIPhone")
component.set("v.isIphone", isIphone);
<aura:attribute name="isIphone" type="boolean" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}" />
<aura:if isTrue="{!v.isIPhone}">
<p> <c:hellomessage message="{!v.messages[0]}"/> </p>
<aura:set attribute="else">
<p> <c:hellomessage message="{!v.messages[1]}"/> </p>
</aura:set>
</aura:if>
component is like this
({
doInit: function(component, event, helper) {
var isIphone=$A.get("$Browser.isIPhone")
component.set("v.isIphone", isIphone);
}
})
Put in controller