Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created May 11, 2018 19:45
Show Gist options
  • Save ChrisMoney/0d964294840e5c744d2d740d8debadba to your computer and use it in GitHub Desktop.
Save ChrisMoney/0d964294840e5c744d2d740d8debadba to your computer and use it in GitHub Desktop.
Angular Edit Modal TS File
import {Component, OnInit, Inject, Output, EventEmitter} from '@angular/core';
import {MatDialogRef, MAT_DIALOG_DATA} from '@angular/material';
// Models
import { Document } from './../../../binders/models/document.model';
import { DocumentContents } from '../../../models/document-contents.model';
// Enums
import {FileEditorType} from './file-editor-type.enum';
@Component({
selector: 'app-file-editor',
templateUrl: './file-editor.component.html',
styleUrls: ['./file-editor.component.css']
})
export class FileEditorComponent implements OnInit {
@Output() documentUploaded: EventEmitter<string> = new EventEmitter();
editorType: FileEditorType;
documentContent : DocumentContents;
constructor(
public dialogRef: MatDialogRef<FileEditorComponent>,
@Inject(MAT_DIALOG_DATA) public data
) {}
ngOnInit() {
this.editorType = this.data.type;
this.documentContent = this.data.documentContent;
}
saveFileName(documentContent : DocumentContents): void {
if (documentContent.name.length <= 40) {
this.dialogRef.close(documentContent);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment