File

src/module/components/dialogs/mat-input-dialog/mat-input-dialog.component.ts

Implements

OnInit

Metadata

selector mat-input-dialog
styleUrls ./mat-input-dialog.component.scss
templateUrl ./mat-input-dialog.component.html

Index

Properties
Methods

Constructor

constructor(dialogRef: MatDialogRef, data: MatInputDialogData)
Parameters :
Name Type Optional
dialogRef MatDialogRef<MatInputDialog> No
data MatInputDialogData No

Methods

ngOnInit
ngOnInit()
Returns : void

Properties

color
Type : ThemePalette
Public data
Type : MatInputDialogData
Decorators :
@Optional()
@Inject(MAT_DIALOG_DATA)
Public dialogRef
Type : MatDialogRef<MatInputDialog>
icon
Type : string
placeholder
Type : string
textButton
Type : string
title
Type : string
import {Component, Inject, OnInit, Optional} from '@angular/core';
import {MAT_DIALOG_DATA, MatDialogRef, ThemePalette} from '@angular/material';

export interface MatInputDialogData {
  title?: string;
  color?: ThemePalette;
  icon?: string;
  appearance?: string;
  placeholder?: string;
  textButton?: string;
}

@Component({
  selector: 'mat-input-dialog',
  templateUrl: './mat-input-dialog.component.html',
  styleUrls: ['./mat-input-dialog.component.scss']
})
export class MatInputDialog implements OnInit {

  title: string;
  icon: string;
  color: ThemePalette;
  placeholder: string;
  textButton: string;

  constructor(public dialogRef: MatDialogRef<MatInputDialog>,
              @Optional() @Inject(MAT_DIALOG_DATA) public data: MatInputDialogData) {
  }

  ngOnInit() {
    if (this.data) {
      this.title = this.data.title ? this.data.title : 'Enter the data';
      this.icon = this.data.icon ? this.data.icon : 'edit';
      this.color = this.data.color ? this.data.color : 'primary';
      this.placeholder = this.data.placeholder ? this.data.placeholder : '';
      this.textButton = this.data.textButton ? this.data.textButton : 'Ok';
    }
  }

}
<mat-dialog-content fxLayout="column">
  <div class="title">
    {{title}}
  </div>
  <div fxFlex fxLayout="row" fxLayoutAlign="center center">
    <mat-form-field class="example-full-width">
      <input matInput #input [placeholder]="placeholder">
      <mat-icon matSuffix [color]="color">{{icon}}</mat-icon>
    </mat-form-field>
  </div>
</mat-dialog-content>

<mat-dialog-actions fxLayoutAlign="center center">
  <button mat-raised-button
          (click)="dialogRef.close(input.value)"
          [color]="color">
    {{textButton}}
  </button>
</mat-dialog-actions>

./mat-input-dialog.component.scss

.title {
  font-size: 20px;
  margin-top: 16px;
  margin-bottom: 16px;
}
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""