I've made custom svgIcon component from SLDS tutorial to use icons in my Lightning components and apps.
I want to write controller that updates "svgPath" attribute after clicking, so my picture of my icon will change. I've impleneted var with my svgIcon component and used set method for this attribute but it doesn't worked.
<aura:component >
<c:svgIcon aura:id="icon" svgPath="/resource/slds213/assets/icons/standard-sprite/svg/symbols.svg#account" category="standard" size="small" name="account" />
<button class="slds-button slds-button--icon" aria-haspopup="true" onclick="{!c.changeIcon}">
<c:svgIcon class="slds-icon-text-default" svgPath="/resource/slds213/assets/icons/utility-sprite/svg/symbols.svg#down" category="utility" size="xx-small" name="down" />
</button>
</aura:component >
Controller class
({ changeIcon :
function(cmp) {
var item = cmp.find('icon');
item.set("v.svgPath", "/resource/slds213/assets/icons/standard-sprite/svg/symbols.svg#user");
}
})
Do you have any suggestions?
<aura:component > <c:svgIcon aura:id="icon" svgPath="/resource/slds213/assets/icons/standard-sprite/svg/symbols.svg#account" category="standard" size="small" name="account" /> <button class="slds-button slds-button--icon" aria-haspopup="true" onclick="{!c.changeIcon}"> <c:svgIcon class="slds-icon-text-default" svgPath="/resource/slds213/assets/icons/utility-sprite/svg/symbols.svg#down" category="utility" size="xx-small" name="down" /> </button> </aura:component >
({ changeIcon : function(cmp) { var item = cmp.find('icon'); item.set("v.svgPath", "/resource/slds213/assets/icons/standard-sprite/svg/symbols.svg#user"); } })