typescript - How to correctly use angular directives when using [innerHTML]? -


i have sidebar code app text changes based on page being loaded. using switch statement set text [innerhtml] reads from. however, not work when there directives such routerlink. how should properly? way use bunch of *ngif's in html?

html:

<div [innerhtml]="text"></div> 

ts:

check = true; text = '<p>hello world</p>' +        '<div *ngif="check">testing</div>' +        '<a routerlink="/link">this link</a>'; 

set text :

    check = true;     text = '<p>hello world</p>' +     '<div *ngif="'+check+'">testing</div>' +     '<a routerlink="/link">this link</a>'; 

it equivalent to:

<p>hello world</p> <div *ngif="true">testing</div><a routerlink="/link">this link</a> 

which *ngif="check" when check = true


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -