Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input number in Angular Material Design?

There is the standard input as:

 <input type="number" placeholder="Hours">

Is there something in Angular Material Design?

enter image description here

I use Angular latest version

I tried this, but it is just simple input:

<md-input-container>
  <input mdInput type="number" placeholder="Favorite food" value="Sushi">
</md-input-container>

It should be < md-input-container input="number">? ot input type="number"> ?

like image 418
Daniel Avatar asked Aug 03 '17 14:08

Daniel


People also ask

What is Mat input?

matInput is a directive that allows native <input> and <textarea> elements to work with <mat-form-field> .

What is MatFormFieldControl?

MatFormFieldControl. An interface which allows a control to work inside of a MatFormField .

What is placeholder in Angular?

Placeholders can be used to enhance the experience of your application. You will, need set some custom widths to toggle their visibility. Their appearance, color, and sizing can be easily customized with our utility classes.


3 Answers

In short, yes. You want < md-input-container > wrapper which supports the following input types

  1. date
  2. datetime-local
  3. email
  4. month
  5. number
  6. password
  7. search
  8. tel
  9. text
  10. time
  11. url
  12. week

For example

<md-input-container>
    <input
        mdInput
        type="number"
        id="myNumber"
    />
</md-input-container>

Checkout https://material.angular.io/components/input/overview

like image 96
prime Avatar answered Oct 26 '22 22:10

prime


Use this for angular material number,

<mat-form-field>
  <input
    type="number"
    class="form-control"
    matInput
    name="value"
    placeholder="Slab"
    (change)="xxx()"
    formControlName="value">
</mat-form-field>
like image 27
Abdus Salam Azad Avatar answered Oct 26 '22 22:10

Abdus Salam Azad


This one is not working anymore

<md-input-container></md-input-container>

This works fine..

<mat-label>Time</mat-label>
    <input type="number" class="form-control" matInput name="time" placeholder="Time" change)="xxx($event)" formControlName="time" required>

In .TS file, you can have the change event with xxx (e) { console.log(e); }

like image 1
Viraj Sandaruwan Avatar answered Oct 26 '22 21:10

Viraj Sandaruwan