Sample Code:
Lightning Component:
Lightning Component:
- <aura:component implements = “force:appHostable”>
- <aura:attribute name = “str” type = “String”/>
- <aura:handler name = “init” value = “{!this}” action = “{!c.onInit}”/>
- <div class = “slds-box slds-theme_default”>
- String is {! v.str }
- </div>
- </aura:component>
Lightning Controller:
- ({
- onInit : function( component, event, helper ) {
- var temp = ‘testing’;
- var tmp = temp.substr( -2 );
- component.set( “v.str”, tmp );
- }
- })
Output: