Short story: I have some iconography needs that aren’t all fulfilled by the ionicons library. I had been dealing with them by sticking them in img tags or elsewhere, but I decided to try and see what would happen if I made an ion-icon
element without a name attribute. It seems to work (in particular, the icon displays at a reasonable size and behaves like an ion-icon in its parent components without me needing to reproduce the css stuff that attaches to ion-icon on my own). This doesn’t seem like documented behavior though, so I thought I’d ask if I’m Playing With Fire here:
<ion-list item-left>
<ion-item>
<ion-icon item-left [inlineSVG]="'/assets/trellisIcons.min.svg#svg-icon-chat'"></ion-icon>
<p>{{community.relationships.conversations.length}}</p>
</ion-item>
<ion-item>
<ion-icon item-left [inlineSVG]="'/assets/trellisIcons.min.svg#svg-icon-torsos-all'"></ion-icon>
<p>{{community.relationships.members.length}}</p>
</ion-item>
</ion-list>
This ends up working fine - I have an icons SVG file that’s got a lot of symbols in it, which I can easily recycle from my vanilla angular 1 version of the app (which I’d injected into index.html as a gulp task back then)
I’m using the excellent ng-inline-svg
library to handle actually dealing with getting the svgs in place (there’s a lot of uneven behavior across browsers when trying to do a plain old use
tag, I’ve found, so having this take care of things is just simpler.)
So the question is: do people do this? Is it legit? Not sure. FWIW, if the ionicons service allowed me to register new icons, I could do it that way instead, but I couldn’t find any documentation about that.