Created
May 11, 2018 19:45
-
-
Save ChrisMoney/0d964294840e5c744d2d740d8debadba to your computer and use it in GitHub Desktop.
Angular Edit Modal TS File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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