import { Directive , TemplateRef , ViewContainerRef , Input } from '@angular/core' ; @ Directive ( { selector : '[appTimes]' } ) export class TimesDirective { constructor ( private viewContainer , private templateRef ) { } @ Input ( 'appTimes' ) set render ( times ) { this . viewContainer . clear ( ) ; for ( let i = 0 ; i < times ; i ++ ) { this . viewContainer . createEmbeddedView ( this . templateRef , { index : i } ) ; } } }