- GlobalPositionStrategy: 当overlay的PositionStrategy设置成GlobalPositionStrategy的时候,overlay的位置是相对整个窗口而言的。
- ConnectedPositionStrategy: 当overlay的位置须要依赖于另一个视图的位置的时候采用该ConnectedPositionStrategy来肯定overlay的位置。可使用FlexibleConnectedPositionStrategy来代替
- 可使用FlexibleConnectedPositionStrategy来代替: overlay的位置依赖于某个视图的位置。
- NoopScrollStrategy: origin滚动的时候,overlay位置不动
- CloseScrollStrategy: origin位置变更的时候,overlay会自动关掉
- BlockScrollStrategy: origin的滚动也会消失掉
- RepositionScrollStrategy: overlay会跟着origin位置的变更而变更
表示经过ComponentFactory建立的组件的实例。 ComponentRef提供对组件实例的访问以及与此组件实例相关的其余对象,并容许您经过destroy方法销毁组件实例。bash
所包含的属性:oop
- C
- location : ElementRef 组件实例的宿主元素所在的位置
- injector : Injector 组件实例存在的注射器
- instance : C 组件实例 [这次主要用到这个属性,能够在service中调用该组件实例上的方法]
- hostview : ViewRef 组件实例的宿主视图ViewRef
- changeDetectorRef : ChangeDetectorRef 组件的ChangeDetectorRef
- componentType: Type 组件类型
- destroy() : void 销毁组件实例及其附加数据
- onDestroy(callback: Function) : void 容许注册将在组件销毁时调用的回调
export testClass{
// 首先在一个service中引入NotificationTestComponent,这个就是要经过引入此service会显示的内容
private _notificationTestRef: ComponentRef<NotificationTestComponent>;
private _overlayRef: OverlayRef;
// 调用 overlay.create() 会返回一个OverlayRef 实例. 这个实例用来处理具体的一个overlay
// this._overlayRef 是一个 PortalOutlet- 一旦建立能够经过attach Portal添加内容
private _createNotificationTest(): void {
this._overlayRef = this._overlay.create();
this._notificationRef = this._overlayRef.attach(new ComponentPortal(NotificationComponent));
}
}
复制代码