The fix: <i innerhtml="<i class='${iconClass}'></i>"></i>
Last active
May 16, 2018 10:09
-
-
Save bryandh/672fbb164896cc72d0ed61d494ed04c2 to your computer and use it in GitHub Desktop.
Font Awesome 5 icon binding issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<p>Original (not working) '${iconClass}'</p> | |
<p> | |
icon => <i class.bind="iconClass"></i> | |
</p> | |
<p>Workaround (working) '${iconClassWorkaround}'</p> | |
<p repeat.for="icon of iconClassWorkaround"> | |
icon => <i class.bind="icon"></i> | |
</p> | |
<p>Fix (simple)</p> | |
<p> | |
icon => <i innerhtml="<i class='${iconClass}'></i>"></i> | |
</p> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class App | |
{ | |
iconClass = 'fas fa-cog'; | |
iconClassWorkaround = ['fas fa-cog']; | |
constructor() | |
{ | |
// Normal icon change by class (not working) | |
setTimeout(() => { | |
this.iconClass = 'fas fa-arrow-left' | |
}, 2000); | |
// Change the icon using a *dirty* workaround (working) | |
setTimeout(() => { | |
this.iconClassWorkaround = []; | |
setTimeout(() => { | |
this.iconClassWorkaround = ['fas fa-arrow-left'] | |
}); | |
}, 2000) | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1" /> | |
<script defer src="https://use.fontawesome.com/releases/v5.0.6/js/all.js"></script> | |
</head> | |
<body aurelia-app=""> | |
Loading... | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/jspm_packages/system.js"></script> | |
<script src="https://cdn.rawgit.com/jdanyow/aurelia-bundle/v1.0.3/config.js"></script> | |
<script> | |
System.import('aurelia-bootstrapper'); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment