Skip to content

Class: DialogBelonging

Boris Jenicek edited this page Oct 22, 2021 · 5 revisions

Class: DialogBelonging<CustomData>

This is the class that needs to be added as DI in the constructor of a child component that will be opened dynamically with DialogInitializer. It contains various information or event controllers, and listeners that can be used in a child component. Also, there is custom data that is sent from component where the DialogInitializer is. User can set specific type of custom data that child component will receive by including it as generic type.

Example:

import {DialogBelonging} from 'ngx-awesome-popup';
@Component({
   selector   : 'app-dynamic',
   templateUrl: './dynamic.component.html',
   styleUrls  : ['./dynamic.component.scss']
})
export class DynamicComponent implements OnInit, OnDestroy {

   subscriptions: Subscription = new Subscription();

   constructor(@Inject('dialogBelonging') private dialogBelonging: DialogBelonging) {}

   ngOnInit(): void {
   console.log(this.dialogBelonging);

       this.subscriptions.add(
           this.dialogBelonging.EventsController.onButtonClick$.subscribe((_Button) => {
           if (_Button.ID === 'ok') {
               // Do some logic and close popup.
               this.dialogBelonging.EventsController.close();
           } else if (_Button.ID === 'cancel') {
               // Do some logic and close popup.
               this.dialogBelonging.EventsController.close();
           }
       })
       );

       setTimeout(() => {
           // Close loader after async data is ready.
           this.dialogBelonging.EventsController.closeLoader();
       }, 1000);
   }
}

ngOnDestroy(): void {
// Close all subscriptions.
this.subscriptions.unsubscribe();
}

Type parameters

Name Default
CustomData any

Hierarchy

  • DialogSettings

    DialogBelonging

Implements

  • IDialogBelonging

Constructors

constructor

+ new DialogBelonging<CustomData>(): DialogBelonging<CustomData>

Type parameters:

Name Default
CustomData any

Returns: DialogBelonging<CustomData>

Overrides: DialogSettings.constructor

Properties

Buttons

Buttons: IButton[]= []

Implementation of: IDialogBelonging.Buttons

Inherited from: DialogSettings.Buttons


CustomData

CustomData: CustomData

Implementation of: IDialogBelonging.CustomData


DialogCoreConfig

DialogCoreConfig: IDialogCoreConfig

Implementation of: IDialogBelonging.DialogCoreConfig

Inherited from: DialogSettings.DialogCoreConfig


EventsController

EventsController: IDialogEventsController

Implementation of: IDialogBelonging.EventsController

Clone this wiki locally