Instantiate a ExampleViewer for each example.
(componentName: string, componentClass: Type<ExampleViewer | HeaderLink>)
| 184 | |
| 185 | /** Instantiate a ExampleViewer for each example. */ |
| 186 | private _loadComponents(componentName: string, componentClass: Type<ExampleViewer | HeaderLink>) { |
| 187 | const exampleElements = this._elementRef.nativeElement.querySelectorAll(`[${componentName}]`); |
| 188 | |
| 189 | [...exampleElements].forEach((element: Element) => { |
| 190 | const example = element.getAttribute(componentName); |
| 191 | const region = element.getAttribute('region'); |
| 192 | const file = element.getAttribute('file'); |
| 193 | const portalHost = new DomPortalOutlet(element, this._appRef, this._injector); |
| 194 | const examplePortal = new ComponentPortal(componentClass, this._viewContainerRef); |
| 195 | const exampleViewer = portalHost.attach(examplePortal); |
| 196 | const exampleViewerComponent = exampleViewer.instance; |
| 197 | if (example !== null) { |
| 198 | if (componentClass === ExampleViewer) { |
| 199 | DocViewer._initExampleViewer( |
| 200 | exampleViewerComponent as ExampleViewer, |
| 201 | example, |
| 202 | file, |
| 203 | region, |
| 204 | ); |
| 205 | } else { |
| 206 | (exampleViewerComponent as HeaderLink).example.set(example); |
| 207 | } |
| 208 | } |
| 209 | this._portalHosts.push(portalHost); |
| 210 | }); |
| 211 | } |
| 212 | |
| 213 | private _clearLiveExamples() { |
| 214 | this._portalHosts.forEach(h => h.dispose()); |
no test coverage detected