0

I'm pretty new to Angular 2 - and have a "simple" question

I have a web service, which delivers content to a view .. in a web service response i want to loop a member array in the template ..

eg.

name = 'testtest';

feed = [{title: 'test'}, {title: 'test42'}];

view.html:

<div class="content" [innerHTML]="page._content"></div>

view.ts:

this.page['_content'] = this.sanitizer.bypassSecurityTrustHtml(this.page['content']);

web service html: this.page['content']:

{{name}} <li class="item" *ngFor="let entry of feed"> ....

result:

{{name}}
pkdkk
  • 3,905
  • 8
  • 44
  • 69
  • You can't bind angular templating syntax into [innerHTML]. Check [this thread](https://stackoverflow.com/q/40473910/6678754) for a possible approach. – Marc Pérez May 30 '17 at 09:52

1 Answers1

1

Tell me if this solves your problem, of binding angular syntaxes into [innerHTML]

The Fantabulous ng-dynamic

and it's usage is also pretty simple:

<div *dynamicComponent="your_html_string">loadin</div>

It binds with angular2+ directives

Good Luck

Ronny McNamara
  • 146
  • 1
  • 4
  • 17