Want to open the standard file open dialog when clicking follow button in the .component.html:
<button md-fab md-tooltip="Input">
<md-icon class="md-24">input</md-icon>
</button>
seems the common way to open a dialog is to use input tag like this:
<input type=”file”>
but it shows extra things on screen. Thinking of do popping up in the .component.ts with a (click) in the :
<button md-fab md-tooltip="Input" (click)="onClick()">
<md-icon class="md-24">input</md-icon>
</button
but couldn't find a way to pop up file open dialog in .ts, please help.
@angular/cli: 1.0.1 node: 7.7.4 os: win32 x64 @angular/xxxx: 4.0.3
It seems you are using angular material. Have you tried to follow this example? https://material.angular.io/components/component/dialog. Current code is taken directly from the example in the link. in the html:
<button md-button (click)="openDialog()">Launch dialog</button>
And in the .ts file:
import {Component} from '@angular/core';
import {MdDialog, MdDialogRef} from '@angular/material';
@Component({
selector: 'dialog-result-example',
templateUrl: './dialog-result-example.html',
})
export class DialogResultExample {
selectedOption: string;
constructor(public dialog: MdDialog) {}
openDialog() {
let dialogRef = this.dialog.open(DialogResultExampleDialog);
dialogRef.afterClosed().subscribe(result => {
this.selectedOption = result;
});
}
}
@Component({
selector: 'dialog-result-example-dialog',
templateUrl: './dialog-result-example-dialog.html',
})
export class DialogResultExampleDialog {
constructor(public dialogRef: MdDialogRef<DialogResultExampleDialog>) {}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With