2016-12-19 55 views
0

我动态创建像一些组件:Angular 2对动态创建的组件视图进行排序?

let comFac = this.componentFactoryResolver.resolveComponentFactory(com) 
let newCom: ComponentRef<any> = viewContain.createComponent(comFac) 
newCom.changeDetectorRef.detectChanges() 

然后我推newCom到一个临时数组,如:

this.comArr.push(newCom) 

而且viewContain可以显示这些components'view correctly.Now我想动态通过拖动它们等操作对这些组件的视图进行排序。如何使组件被拖动后显示视图,但不能再次创建它们(组件)?

回答

相关问题