Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions goldens/public-api/core/index.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ export class ApplicationRef {
constructor();
attachView(viewRef: ViewRef): void;
bootstrap<C>(component: Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
// @deprecated
bootstrap<C>(componentFactory: ComponentFactory<C>, rootSelectorOrNode?: string | any): ComponentRef<C>;
readonly components: ComponentRef<any>[];
readonly componentTypes: Type<any>[];
destroy(): void;
Expand Down Expand Up @@ -293,31 +291,6 @@ export interface ComponentDecorator {
new (obj: Component): Component;
}

// @public @deprecated
export abstract class ComponentFactory<C> {
abstract get componentType(): Type<any>;
abstract create(injector: Injector, projectableNodes?: any[][], rootSelectorOrNode?: string | any, environmentInjector?: EnvironmentInjector | NgModuleRef<any>, directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[], bindings?: Binding[]): ComponentRef<C>;
abstract get inputs(): {
propName: string;
templateName: string;
transform?: (value: any) => any;
isSignal: boolean;
}[];
abstract get ngContentSelectors(): string[];
abstract get outputs(): {
propName: string;
templateName: string;
}[];
abstract get selector(): string;
}

// @public @deprecated
export abstract class ComponentFactoryResolver {
// (undocumented)
static NULL: ComponentFactoryResolver;
abstract resolveComponentFactory<T>(component: Type<T>): ComponentFactory<T>;
}

// @public
export interface ComponentMirror<C> {
get inputs(): ReadonlyArray<{
Expand Down Expand Up @@ -2072,8 +2045,6 @@ export abstract class ViewContainerRef {
directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[];
bindings?: Binding[];
}): ComponentRef<C>;
// @deprecated
abstract createComponent<C>(componentFactory: ComponentFactory<C>, index?: number, injector?: Injector, projectableNodes?: any[][], environmentInjector?: EnvironmentInjector | NgModuleRef<any>, directives?: (Type<unknown> | DirectiveWithBindings<unknown>)[], bindings?: Binding[]): ComponentRef<C>;
abstract createEmbeddedView<C>(templateRef: TemplateRef<C>, context?: C, options?: {
index?: number;
injector?: Injector;
Expand Down
78 changes: 12 additions & 66 deletions packages/core/src/application/application_ref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import '../util/ng_hmr_mode';
import '../util/ng_jit_mode';
import '../util/ng_server_mode';

import {type Observable, Subject, type Subscription} from 'rxjs';
import {map} from 'rxjs/operators';
import {
setActiveConsumer,
getActiveConsumer,
setActiveConsumer,
setThrowInvalidWriteToSignalError,
} from '../../primitives/signals';
import {type Observable, Subject, type Subscription} from 'rxjs';
import {map} from 'rxjs/operators';

import {ZONELESS_ENABLED} from '../change_detection/scheduling/zoneless_scheduling';
import {Console} from '../console';
Expand All @@ -25,8 +25,8 @@ import {Injectable} from '../di/injectable';
import {InjectionToken} from '../di/injection_token';
import {Injector} from '../di/injector';
import {EnvironmentInjector, type R3Injector} from '../di/r3_injector';
import {formatRuntimeError, RuntimeError, RuntimeErrorCode} from '../errors';
import {INTERNAL_APPLICATION_ERROR_HANDLER} from '../error_handler';
import {formatRuntimeError, RuntimeError, RuntimeErrorCode} from '../errors';
import {Type} from '../interface/type';
import {ComponentFactory, ComponentRef} from '../linker/component_factory';
import {ComponentFactoryResolver} from '../linker/component_factory_resolver';
Expand All @@ -44,10 +44,10 @@ import {ViewRef as InternalViewRef} from '../render3/view_ref';
import {TESTABILITY} from '../testability/testability';
import {NgZone} from '../zone/ng_zone';

import {profiler} from '../render3/profiler';
import {ProfilerEvent} from '../../primitives/devtools';
import {EffectScheduler} from '../render3/reactivity/root_effect_scheduler';
import {profiler} from '../render3/profiler';
import {isReactiveLViewConsumer} from '../render3/reactive_lview_consumer';
import {EffectScheduler} from '../render3/reactivity/root_effect_scheduler';
import {ApplicationInitStatus} from './application_init';
import {TracingAction, TracingService, TracingSnapshot} from './tracing';

Expand Down Expand Up @@ -441,61 +441,13 @@ export class ApplicationRef {
* While in this example, we are providing reference to a DOM node.
*
* {@example core/ts/platform/platform.ts region='domNode'}
*
* @deprecated Passing Component factories as the `Application.bootstrap` function argument is
* deprecated. Pass Component Types instead.
*/
bootstrap<C>(
componentFactory: ComponentFactory<C>,
rootSelectorOrNode?: string | any,
): ComponentRef<C>;

/**
* Bootstrap a component onto the element identified by its selector or, optionally, to a
* specified element.
*
* @usageNotes
* ### Bootstrap process
*
* When bootstrapping a component, Angular mounts it onto a target DOM element
* and kicks off automatic change detection. The target DOM element can be
* provided using the `rootSelectorOrNode` argument.
*
* If the target DOM element is not provided, Angular tries to find one on a page
* using the `selector` of the component that is being bootstrapped
* (first matched element is used).
*
* ### Example
*
* Generally, we define the component to bootstrap in the `bootstrap` array of `NgModule`,
* but it requires us to know the component while writing the application code.
*
* Imagine a situation where we have to wait for an API call to decide about the component to
* bootstrap. We can use the `ngDoBootstrap` hook of the `NgModule` and call this method to
* dynamically bootstrap a component.
*
* {@example core/ts/platform/platform.ts region='componentSelector'}
*
* Optionally, a component can be mounted onto a DOM element that does not match the
* selector of the bootstrapped component.
*
* In the following example, we are providing a CSS selector to match the target element.
*
* {@example core/ts/platform/platform.ts region='cssSelector'}
*
* While in this example, we are providing reference to a DOM node.
*
* {@example core/ts/platform/platform.ts region='domNode'}
*/
bootstrap<C>(
componentOrFactory: ComponentFactory<C> | Type<C>,
rootSelectorOrNode?: string | any,
): ComponentRef<C> {
return this.bootstrapImpl(componentOrFactory, rootSelectorOrNode);
bootstrap<C>(component: Type<C>, rootSelectorOrNode?: string | any): ComponentRef<C> {
return this.bootstrapImpl(component, rootSelectorOrNode);
}

private bootstrapImpl<C>(
componentOrFactory: ComponentFactory<C> | Type<C>,
component: Type<C>,
rootSelectorOrNode?: string | any,
injector: Injector = Injector.NULL,
): ComponentRef<C> {
Expand All @@ -504,13 +456,12 @@ export class ApplicationRef {
profiler(ProfilerEvent.BootstrapComponentStart);

(typeof ngDevMode === 'undefined' || ngDevMode) && warnIfDestroyed(this._destroyed);
const isComponentFactory = componentOrFactory instanceof ComponentFactory;
const initStatus = this._injector.get(ApplicationInitStatus);

if (!initStatus.done) {
let errorMessage = '';
if (typeof ngDevMode === 'undefined' || ngDevMode) {
const standalone = !isComponentFactory && isStandalone(componentOrFactory);
const standalone = isStandalone(component);
errorMessage =
'Cannot bootstrap as there are still asynchronous initializers running.' +
(standalone
Expand All @@ -520,13 +471,8 @@ export class ApplicationRef {
throw new RuntimeError(RuntimeErrorCode.ASYNC_INITIALIZERS_STILL_RUNNING, errorMessage);
}

let componentFactory: ComponentFactory<C>;
if (isComponentFactory) {
componentFactory = componentOrFactory;
} else {
const resolver = this._injector.get(ComponentFactoryResolver);
componentFactory = resolver.resolveComponentFactory(componentOrFactory)!;
}
const resolver = this._injector.get(ComponentFactoryResolver);
const componentFactory = resolver.resolveComponentFactory(component)!;
this.componentTypes.push(componentFactory.componentType);

// Create a factory associated with the current module if it's not bound to some other
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/linker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export {
CompilerOptions,
ModuleWithComponentFactories,
} from './linker/compiler';
export {ComponentFactory, ComponentRef} from './linker/component_factory';
export {ComponentFactoryResolver} from './linker/component_factory_resolver';
export {ComponentRef, ComponentFactory as ɵComponentFactory} from './linker/component_factory';
export {ComponentFactoryResolver as ɵComponentFactoryResolver} from './linker/component_factory_resolver';
export {DestroyRef} from './linker/destroy_ref';
export {ElementRef} from './linker/element_ref';
export {NgModuleFactory, NgModuleRef} from './linker/ng_module_factory';
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/linker/component_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ export abstract class ComponentRef<C> {
* Base class for a factory that can create a component dynamically.
* Instantiate a factory for a given type of component with `resolveComponentFactory()`.
* Use the resulting `ComponentFactory.create()` method to create a component of that type.
*
* @publicApi
*
* @deprecated Angular no longer requires Component factories. Please use other APIs where
* Component class can be used directly.
*/
export abstract class ComponentFactory<C> {
/**
Expand Down
5 changes: 0 additions & 5 deletions packages/core/src/linker/component_factory_resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,6 @@ class _NullComponentFactoryResolver implements ComponentFactoryResolver {
* Note: since v13, dynamic component creation via
* [`ViewContainerRef.createComponent`](api/core/ViewContainerRef#createComponent)
* does **not** require resolving component factory: component class can be used directly.
*
* @publicApi
*
* @deprecated Angular no longer requires Component factories. Please use other APIs where
* Component class can be used directly.
*/
export abstract class ComponentFactoryResolver {
static NULL: ComponentFactoryResolver = /* @__PURE__ */ new _NullComponentFactoryResolver();
Expand Down
Loading
Loading