(element: Element)
| 55 | * @publicApi |
| 56 | */ |
| 57 | export function getComponent<T>(element: Element): T | null { |
| 58 | ngDevMode && assertDomElement(element); |
| 59 | const context = getLContext(element); |
| 60 | if (context === null) return null; |
| 61 | |
| 62 | if (context.component === undefined) { |
| 63 | const lView = context.lView; |
| 64 | if (lView === null) { |
| 65 | return null; |
| 66 | } |
| 67 | context.component = getComponentAtNodeIndex(context.nodeIndex, lView); |
| 68 | } |
| 69 | |
| 70 | return context.component as unknown as T; |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * If inside an embedded view (e.g. `*ngIf` or `*ngFor`), retrieves the context of the embedded |
no test coverage detected
searching dependent graphs…