Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
This repository was archived by the owner on Sep 5, 2024. It is now read-only.

button: enhance to support input types like file #2151

@ThomasBurleson

Description

@ThomasBurleson

mdButton and FABs should be enhanced to support type="file" for built-in default triggers.

Current Solution:

Currently this is the only way to use mdButton to support <input type="file">:

To get <input type="file"> to work with mdButton, you must use a <label for="<link id>" />. See below for working sample:

<html>
  <head>
    <link rel="stylesheet" href="https://rawgit.com/angular/bower-material/master/angular-material.css">
    <style>
      #file-input { display: none; }
    </style>

    <script src="https://code.angularjs.org/1.4.0-beta.6/angular.js"></script>
    <script src="https://code.angularjs.org/1.4.0-beta.6/angular-animate.js"></script>
    <script src="https://code.angularjs.org/1.4.0-beta.6/angular-aria.js"></script>

    <script src="https://rawgit.com/angular/bower-material/master/angular-material.min.js"></script>
  </head>

  <body ng-app="app" >

    <div>
      <h2>File Upload with Material:</h2>

      <md-button>
        <label for="file-input">Select</label>  
      </md-button>
      <input id="file-input" type="file">

    </div>

    <script>
      angular.module('app', ['ngMaterial']);
    </script>

  </body>
</html>

@see Plunkr

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions