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)
}))
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter