@@ -37,6 +37,7 @@ import {RendererFactory2} from '../render/api';
3737import { AfterRenderManager } from '../render3/after_render/manager' ;
3838import { ComponentFactory as R3ComponentFactory } from '../render3/component_ref' ;
3939import { isStandalone } from '../render3/def_getters' ;
40+ import type { Binding , DirectiveWithBindings } from '../render3/dynamic_bindings' ;
4041import { ChangeDetectionMode , detectChangesInternal } from '../render3/instructions/change_detection' ;
4142import { publishDefaultGlobalUtils as _publishDefaultGlobalUtils } from '../render3/util/global_utils' ;
4243import { requiresRefreshOrTraversal } from '../render3/util/view_utils' ;
@@ -375,7 +376,7 @@ export class ApplicationRef {
375376 *
376377 * When bootstrapping a component, Angular mounts it onto a target DOM element
377378 * and kicks off automatic change detection. The target DOM element can be
378- * provided using the `rootSelectorOrNode ` argument.
379+ * provided using the `hostElement ` argument.
379380 *
380381 * If the target DOM element is not provided, Angular tries to find one on a page
381382 * using the `selector` of the component that is being bootstrapped
@@ -403,7 +404,16 @@ export class ApplicationRef {
403404 *
404405 * {@example core/ts/platform/platform.ts region='domNode'}
405406 */
406- bootstrap < C > ( component : Type < C > , rootSelectorOrNode ?: string | any ) : ComponentRef < C > ;
407+ bootstrap < C > (
408+ component : Type < C > ,
409+ options ?: {
410+ hostElement ?: Element | string ;
411+ directives ?: ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] ;
412+ bindings ?: Binding [ ] ;
413+ } ,
414+ ) : ComponentRef < C > ;
415+
416+ bootstrap < C > ( component : Type < C > , hostElement ?: Element | string ) : ComponentRef < C > ;
407417
408418 /**
409419 * Bootstrap a component onto the element identified by its selector or, optionally, to a
@@ -414,7 +424,7 @@ export class ApplicationRef {
414424 *
415425 * When bootstrapping a component, Angular mounts it onto a target DOM element
416426 * and kicks off automatic change detection. The target DOM element can be
417- * provided using the `rootSelectorOrNode ` argument.
427+ * provided using the `hostElement ` argument.
418428 *
419429 * If the target DOM element is not provided, Angular tries to find one on a page
420430 * using the `selector` of the component that is being bootstrapped
@@ -448,7 +458,15 @@ export class ApplicationRef {
448458
449459 private bootstrapImpl < C > (
450460 component : Type < C > ,
451- rootSelectorOrNode ?: string | any ,
461+ hostElementOrOptions ?:
462+ | Element
463+ | string
464+ | undefined
465+ | {
466+ hostElement ?: Element | string | undefined ;
467+ directives ?: ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] ;
468+ bindings ?: Binding [ ] ;
469+ } ,
452470 injector : Injector = Injector . NULL ,
453471 ) : ComponentRef < C > {
454472 const ngZone = this . _injector . get ( NgZone ) ;
@@ -479,8 +497,16 @@ export class ApplicationRef {
479497 const ngModule = isBoundToModule ( componentFactory )
480498 ? undefined
481499 : this . _injector . get ( NgModuleRef ) ;
482- const selectorOrNode = rootSelectorOrNode || componentFactory . selector ;
483- const compRef = componentFactory . create ( injector , [ ] , selectorOrNode , ngModule ) ;
500+ const { hostElement, directives, bindings} = normalizeBootstrapOptions ( hostElementOrOptions ) ;
501+ const selectorOrNode = hostElement || componentFactory . selector ;
502+ const compRef = componentFactory . create (
503+ injector ,
504+ [ ] ,
505+ selectorOrNode ,
506+ ngModule ,
507+ directives ,
508+ bindings ,
509+ ) ;
484510 const nativeElement = compRef . location . nativeElement ;
485511 const testability = compRef . injector . get ( TESTABILITY , null ) ;
486512 testability ?. registerApplication ( nativeElement ) ;
@@ -803,6 +829,32 @@ export class ApplicationRef {
803829 }
804830}
805831
832+ function normalizeBootstrapOptions (
833+ hostElementOrOptions :
834+ | Element
835+ | string
836+ | undefined
837+ | {
838+ hostElement ?: Element | string | undefined ;
839+ directives ?: ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] ;
840+ bindings ?: Binding [ ] ;
841+ } ,
842+ ) : {
843+ hostElement ?: Element | string | undefined ;
844+ directives ?: ( Type < unknown > | DirectiveWithBindings < unknown > ) [ ] ;
845+ bindings ?: Binding [ ] ;
846+ } {
847+ if (
848+ hostElementOrOptions === undefined ||
849+ typeof hostElementOrOptions === 'string' ||
850+ hostElementOrOptions instanceof Element
851+ ) {
852+ return { hostElement : hostElementOrOptions } ;
853+ }
854+
855+ return hostElementOrOptions ;
856+ }
857+
806858function warnIfDestroyed ( destroyed : boolean ) : void {
807859 if ( destroyed ) {
808860 console . warn (
0 commit comments