-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathquiz.directive.ts
37 lines (32 loc) · 1.15 KB
/
quiz.directive.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import {
Directive, Input, Output, EventEmitter, ElementRef,
HostListener, Renderer2, ViewContainerRef, ComponentFactoryResolver, OnInit, OnChanges
} from '@angular/core';
@Directive({
selector: '[quizcontainer]'
})
export class QuizcontainerDirective1 implements OnInit {
@Input() quizData: object;
@Input() quizIndex: number;
@Input() componentName: any;
@Input() alreadyChoosedAns: any;
@Output() close = new EventEmitter<any>();
constructor(
private el: ElementRef,
private ren: Renderer2,
private viewContainer: ViewContainerRef,
private componentFactoryResolver: ComponentFactoryResolver
) { }
ngOnInit() {
}
createQuizComp(comp) {
console.log('CreateModalDialog is called');
this.viewContainer.clear();
const myFactory = this.componentFactoryResolver.resolveComponentFactory(comp);
const myRef = this.viewContainer.createComponent(myFactory);
myRef.instance['data'] = this.quizData;
myRef.instance['serialno'] = quizIndex;
myRef.instance['alreadychoosedans'] = alreadyChoosedAns;
return modalDialogComponentRef;
}
}