Muh*_*ooq 4 angular-material typescript2.0 angular angular-cdk
我想使用overlay.position().flexibleConnectedTo()配置覆盖,因为根据官方文档,connectedTo()已被弃用。否则有一个问题对connectedTo()有一个很好的答案

这是我的代码
const origin:FlexibleConnectedPositionStrategyOrigin=this.RefElem;
const overlayConfig = new OverlayConfig();
overlayConfig.positionStrategy = this.overlay.position().flexibleConnectedTo(origin);
const overlayRef = this.overlay.create(overlayConfig);
const userProfilePortal = new ComponentPortal(
GraphMetaSignalSelectorComponent
);
overlayRef.attach(userProfilePortal);
Run Code Online (Sandbox Code Playgroud)
但出现此错误:“ConnectedToFlexibleConnectedPositionStrategy:至少需要一个位置。在FlexibleConnectedPositionStrategy.push”
Ale*_*nko 12
对于那些因为缺乏 的实现而坚持接受的答案的人来说this.getPositions(),这里有一个复制粘贴的快速示例:
const positionStrategy = this.overlay.position()
.flexibleConnectedTo(origin)
.withPositions([{
// here, top-left of the overlay is connected to bottom-left of the origin;
// of course, you can change this object or generate it dynamically;
// moreover, you can specify multiple objects in this array for CDK to find the most suitable option
originX: 'start',
originY: 'bottom',
overlayX: 'start',
overlayY: 'top'
} as ConnectedPosition])
.withPush(false); // or true, if you want to push the overlay into the screen when it doesn't fit
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4205 次 |
| 最近记录: |