angular - Angular2 Template mixins and helpers -
is there way define helper functions generate html code before compilation time?
for example, nice generate <i class="icon icon-hamburger" aria-hidden="true"></i>
<icon>hamburguer</icon>
without overhead , performance impact of creating component, need translated before template compilation.
it's recommended use aot
(ahead of time compilation) in production, put overhead , performance impact component creation minimum. have want, need create dynamic component, add overhead process, , doesn't work (well) aot
.
a fast directive this:
@directive({ selector: '[jmicon]', host: { 'attr.aria-hidden': 'true' } }) export class icondirective { @input() public jmicon: string; @hostbinding('class') public classlist(): string { return 'icon icon-' + this.jmicon; } }
with usage:
<i jmicon="hamburger"></i>
Comments
Post a Comment