test

PHOTO EMBED

Wed May 25 2022 21:18:01 GMT+0000 (UTC)

Saved by @karevind #typescript

import { Directive, TemplateRef, ViewContainerRef, Input} from '@angular/core';

@Directive({
  selector: '[appNavigationLine]'
})
export class NavigationLineDirective {

  constructor(
    private templateRef: TemplateRef<any>,
    private viewContainer: ViewContainerRef
  ) { }

  @Input('appNavigationLine') set navigationLine(numArray: (number|string)[]) {
    this.viewContainer.clear()
    numArray.forEach( num => this.viewContainer.createEmbeddedView(this.templateRef, {
      index: numArray.indexOf(num)
    }))
  }
}
content_copyCOPY

ngFor like loop using a directive.