# Angular Service

The `PopupService` is an [Angular service](https://angular.dev/guide/di/creating-and-using-services#), which provides API calls that are used to create Popup instances dynamically.

That is, the service helps create Popup instances from TypeScript based on user interactions and without the need to define the component in a template.

## Getting Started

The service allows you to configure different Popup settings. All possible options are defined by the [`PopupSettings`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupsettings) interface.

The following example demonstrates how to set an absolute position for the Popup.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/service/settings/source.txt)

## Creating New Popups

The [Angular dependency injection](https://angular.dev/guide/di/creating-and-using-services#) injects the Popup service automatically in the constructors of the component. To create new Popups, use the [`open`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupservice#open) method.

## Rendering the Content

You can render the content of the Popup by using the following approaches:

* [Using templates](https://www.telerik.com/kendo-angular-ui-develop/components/popup/service#using-templates)
* [Using components](https://www.telerik.com/kendo-angular-ui-develop/components/popup/service#using-components)
* [Appending to specific containers](https://www.telerik.com/kendo-angular-ui-develop/components/popup/service#appending-to-specific-containers)

### Using Templates

The Popup allows the use of template expressions in its content area. To enable this behavior, pass a [`TemplateRef`](https://angular.dev/api/core/TemplateRef) instance.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/service/source.txt)

### Using Components

The Popup also allows the rendering of component types in its content area. To enable this behavior, pass a reference to the dynamically created component in the [`content`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupref#content) field of the result.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/service/component/source.txt)

### Appending to Specific Containers

By default, the Popup gets inserted into the first root component which is available in the `ApplicationRef` class. To change this behavior, use the [`appendTo`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupsettings#appendto) option which specifies a `ViewContainerRef` instance.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/popup/service/container/source.txt)

> tip To set a global default container for all Popup instances created by the `PopupService`, use the [`POPUP_CONTAINER`](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popup_container) injection token. For more details, refer to [Rendering Container for Popup Instances](https://www.telerik.com/kendo-angular-ui-develop/components/popup/rendering-container).

## Suggested Links

* [Popup Container](https://www.telerik.com/kendo-angular-ui-develop/components/popup/rendering-container)
* [API Reference of the Popup](https://www.telerik.com/kendo-angular-ui-develop/components/popup/api/popupcomponent)
