Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

377
Views
Angular 4 TypeScript, click a button to pop file open dialog

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

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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>) {}
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!