MatSelect overlayDir now private when updating from Angular 11 to 12. How do I access it now?

已查看 307 次
跳至第一个未读帖子

Jeremy

未读,
2021年9月15日 13:56:092021/9/15
收件人 angular-material2
In Angular 11, in node_modules\@angular\material\select there is a variable:

```
/**
     * Overlay pane containing the options.
     * @deprecated To be turned into a private API.
     * @breaking-change 10.0.0
     * @docs-private
     */
    overlayDir: CdkConnectedOverlay;
```

that in Angular 12 has now been changed to:
```
/** Overlay pane containing the options. */
    protected _overlayDir: CdkConnectedOverlay;
```

This of course breaks all of my usage of `overlayDir`  For example:

```
let selectionOverlay = this.quickFiltersSelect
              .overlayDir as CdkConnectedOverlay;
```
Gives me the TS error:
```Property 'overlayDir' does not exist on type 'MatSelect'```
...Which makes sense. Now it's protected. So I change .overlayDir to ._overlayDir and now get the TS error:
```
Property '_overlayDir' is protected and only accessible within class '_MatSelectBase<C>' and its subclasses.
```

I then imported _MatSelectBase but I am not sure what to replace it with, or if I should be accessing protected properties in this manner. I think `_MatSelectBase` is a generic, so it is looking for `_MatSelectBase<C>` but I am no longer sure I am on the right path.

Can anyone tell me where I have gone wrong, and what the solution might be?

Thank you.
回复全部
回复作者
转发
0 个新帖子