# ModalRef Type documentation

## TypeScript declaration

### [ModalRef](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L15-L78>)

**Kind:** class

```
import { ModalRef } from '@siemens/element-ng/modal';
```

Reference to a modal dialog

```
undecorated_class ModalRef<T = never, CT = any>
```

#### Constructor

##### constructor

[Source for constructor](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L15-L78>)

```
constructor(): ModalRef<T, CT>
```

**Returns:** [ModalRef](<index.html#t:ModalRef>)`<T, CT>`

#### Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [closeValue](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L44-L44>) (optional) | `CT` |  | The default close value of the modal. |
| [data](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L28-L28>) | `ModalOptions<Record<string, any>>` | `` `{}` `` | The modal options passed during creation.<br><br>See: [SiModalService](<../../injectables/SiModalService/index.html#SiModalService>) |
| [detach](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L60-L60>) | `() => void` | `` `() => {}` `` |  |
| [dialogClass](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L36-L36>) | `string` | `''` | Custom class for modal-dialog |
| [hidden](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L17-L17>) | `Subject<CT \| undefined>` | `new Subject<CT \| undefined>()` | Emits the close value when the modal is hidden. |
| [hide](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L66-L66>) | `(reason?: CT) => void` | `` `() => {}` `` | Close the modal with a custom close value. |
| [ignoreBackdropClick](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L30-L30>) | `boolean` | `true` |  |
| [isCurrent](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L56-L56>) | `() => boolean` | `` `() => false` `` |  |
| [layer](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L42-L42>) | `number` | `0` | The layer of the modal. The modal with the highest layer will be shown on top. |
| [message](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L19-L19>) | `Subject<CT \| undefined>` | `new Subject<CT \| undefined>()` | Allows messaging state to consumer w/o closing the dialog. |
| [shown](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L21-L21>) | `ReplaySubject<ElementRef<any>>` | `new ReplaySubject<ElementRef>(1)` | Emits the modal element reference when it is shown. |

#### Accessors

| Name | Type | Description |
| --- | --- | --- |
| [content](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L46-L48>) (readonly) | `T` |  |

#### Methods

##### messageOrHide

[Source for messageOrHide](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L71-L77>)

When `data.disableAutoHide` is set, messages the `reason`, otherwise calls [hide](<index.html#t:ModalRef.hide>).

```
messageOrHide(reason?: CT): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [reason](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L71-L71>) (optional) | `CT` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### setInput

[Source for setInput](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L51-L51>)

Set the input of a component shown in the modal.

```
setInput(input: string, value: unknown): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [input](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L51-L51>) | `string` |  |  |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/modalref.ts#L51-L51>) | `unknown` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### Types Documentation

### [ModalOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L34-L57>)

**Kind:** interface

```
import type { ModalOptions } from '@siemens/element-ng/modal';
```

```
interface ModalOptions<T = Record<string, any>> extends ModalDependencyInjectionOptions
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [animated](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L52-L52>) (optional) | `boolean` | Whether to enable animation. |
| [ariaLabelledBy](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L56-L56>) (optional) | `string` | aria-labelled-by value. |
| [bindings](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L39-L39>) (optional) | `Binding[]` | Angular bindings for component content, created with `inputBinding`, `outputBinding`, or `twoWayBinding`. Ignored for template content. |
| [class](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L54-L54>) (optional) | `string` | Additional CSS class. |
| [environmentInjector](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L31-L31>) (optional, inherited) | `EnvironmentInjector` | Optional environment Injector.<br><br>Inherited from [ModalDependencyInjectionOptions](<index.html#t:ModalDependencyInjectionOptions>) |
| [ignoreBackdropClick](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L46-L46>) (optional) | `boolean` | When set to true, clicking the backdrop has no effect. |
| [injector](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L29-L29>) (optional, inherited) | `Injector` | Optional element Injector.<br><br>Inherited from [ModalDependencyInjectionOptions](<index.html#t:ModalDependencyInjectionOptions>) |
| [inputValues](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L44-L44>) (optional) | `Record<string, unknown>` | Use this to assign values to either `@Input()` or `input()` fields of the provided component. If a template is used, the values are available in the template context. |
| [keyboard](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L50-L50>) (optional) | `boolean` | Handle Esc to close/message. |
| [messageInsteadOfAutoHide](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L48-L48>) (optional) | `boolean` | When set to true, backdrop click or Esc don't close the modal. Instead a message will be sent. |
| [providers](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L27-L27>) (optional, inherited) | `StaticProvider[]` | Additional providers for the modal.<br><br>Inherited from [ModalDependencyInjectionOptions](<index.html#t:ModalDependencyInjectionOptions>) |

### [ModalDependencyInjectionOptions](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L25-L32>)

**Kind:** interface

```
import type { ModalDependencyInjectionOptions } from '@siemens/element-ng/modal';
```

```
interface ModalDependencyInjectionOptions
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [environmentInjector](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L31-L31>) (optional) | `EnvironmentInjector` | Optional environment Injector. |
| [injector](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L29-L29>) (optional) | `Injector` | Optional element Injector. |
| [providers](<https://github.com/siemens/element/blob/main/projects/element-ng/modal/si-modal.service.ts#L27-L27>) (optional) | `StaticProvider[]` | Additional providers for the modal. |
