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

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -