Sikander
Sikander

Reputation: 656

Unable to read callback function in template function in angular2

I am trying to display the dynamic html in template function but not able to do so:

@Component({
  selector: 'hero-host',
  template: getHTML(),
  styles: ['.active {background-color: yellow;}']
})
export class HeroHostComponent {
getHTML(){
return '<ul class="page-sidebar-menu"><li class="sidebar-toggler-wrapper hide"><div class="sidebar-toggler"> </div></li><li class="sidebar-search-wrapper"></li><li class="nav-item start"><a class="nav-link home name" (click)="HomeButton(event)"><i class="fa fa-home"></i><span class="title">Home</span></a></li><li class="nav-item"><a class="nav-link nav-toggle masters" (click)="parentNav($event)"><i class="fa fa-diamond"></i><span class="title">Master Files</span><span class="arrow"></span><span class=""></span></a><ul class="sub-menu"><a class="nav-link nav-toggle masters" (click)="parentNav($event)"></a>';   
}
}

Please help me if I am doing wrong. Thanks in advance.

Upvotes: 0

Views: 25

Answers (1)

mic4ael
mic4ael

Reputation: 8290

Replace getHTML() call (template key inside Component decorator) with the string you return from this method.

According to the docs:

template - inline-defined template for the view

Upvotes: 1

Related Questions