This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AppComponent.ɵfac = function AppComponent_Factory(t) { | |
return new (t || AppComponent)( | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"](FOO), | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"](BAR, 8), | |
_angular_core__WEBPACK_IMPORTED_MODULE_0__["ɵɵdirectiveInject"]( | |
_angular_common_http__WEBPACK_IMPORTED_MODULE_1__.HttpClient | |
), | |
... | |
); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Directive({ | |
standalone: true, | |
selector: 'img[rawSrc]', | |
}) | |
export class NgOptimizedImage implements OnInit, OnChanges, OnDestroy { | |
private imageLoader = inject(IMAGE_LOADER); | |
private renderer = inject(Renderer2); | |
private imgElement: HTMLImageElement = inject(ElementRef).nativeElement; | |
private injector = inject(Injector); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
private foo = inject(FOO) // typed as string | |
private bar = inject(BAR, { optional: true }) // typed as string | null | |
private http = inject(HttpClient) // typed as HttpClient | |
private todosService = inject(TodosService) // typed as TodosService | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
private foo = inject(FOO) | |
private bar = inject(BAR, { optional: true }) | |
private http = inject(HttpClient); | |
private todosService = inject(TodosService); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class AppComponent { | |
constructor( | |
@Inject(FOO) private foo: string, | |
@Optional() @Inject(BAR) private bar: string | null, | |
private http: HttpClient, | |
private todosService: TodosService | |
) { } | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, ElementRef, inject } from '@angular/core'; | |
import { App } from '@myorg/app-name'; | |
import { NgReact } from '@myorg/ng-react'; | |
@Component({ | |
standalone: true, | |
template: `` | |
}) | |
export class TodosPageComponent { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import NxWelcome from './nx-welcome'; | |
export function App() { | |
return ( | |
<> | |
<NxWelcome title="react-platform" /> | |
... | |
</> | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... THE CONTEXT CODE IS ABOVE ... | |
@Injectable({ providedIn: 'root' }) | |
export class NgReact { | |
injector = inject(Injector); | |
createRoot(host: HTMLElement) { | |
return createRoot(host); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injector } from '@angular/core'; | |
import { PropsWithChildren, createContext, useContext } from 'react'; | |
import { createRoot, Root } from 'react-dom/client' | |
const InjectorCtx = createContext<Injector | null>(null) | |
export function NgContext(props: PropsWithChildren<{ injector: Injector }>) { | |
return createElement(InjectorCtx.Provider, { | |
children: props.children, | |
value: props.injector |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { CommonModule } from '@angular/common'; | |
import { Component, ElementRef, OnDestroy, OnInit } from '@angular/core'; | |
import type { ComponentProps } from 'react'; | |
@Component({ | |
standalone: true, | |
imports: [CommonModule, LazyReactComponentDirective], | |
template: ` | |
<h1>Todos page</h1> | |
<button (click)="showSelect = true">Show React Component</button> |