答案 0 :(得分:1)
一旦在视图控制器中获得了滑动手势,便执行下一个操作:
open(component: Type<Modal>): void {
if (this.modalRef)
return;
this.elementRef = this.componentFactoryResolver
.resolveComponentFactory(component)
.create(this.injector);
this.appRef.attachView(this.elementRef.hostView);
this.elementRef.instance.modal = this;
this.modalRef = this.componentFactoryResolver
.resolveComponentFactory(ModalComponent)
.create(this.injector, [[this.elementRef.location.nativeElement]]);
\/
here we're projecting inner component into modal
this.appRef.attachView(this.modalRef.hostView);
document.body.appendChild(this.modalRef.location.nativeElement);
}
close(): void {
this.appRef.detachView(this.elementRef.hostView);
this.elementRef.destroy();
this.elementRef = null;
this.appRef.detachView(this.modalRef.hostView);
this.modalRef.destroy();
this.modalRef = null;
}
myViewModels是要显示的对象数组(包含数据,颜色等) 除了更新,您还可以手动更新必要的字段
代码可能有错误,但思路应该清晰