Input number in Angular Material Design?

非 Y 不嫁゛ 提交于 2020-01-31 07:59:24

问题


There is the standard input as:

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

Is there something in Angular Material Design?

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"> ?


回答1:


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




回答2:


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>


来源:https://stackoverflow.com/questions/45487647/input-number-in-angular-material-design

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!