【问题标题】:how should i use select tag dropdown from angular2-material design for angular2-app我应该如何从 angular2-material 设计中为 angular2-app 使用选择标签下拉菜单
【发布时间】:2016-12-11 20:23:03
【问题描述】:

我正在使用@angular2-materail 组件来构建我的应用程序并格式化表单输入元素。我正在使用md-inputmd-checkbox 等,但没有找到任何组件来显示选择下拉菜单。有什么组件可以用来格式化select 下拉菜单吗?

【问题讨论】:

    标签: angular angular-cli angular-material2


    【解决方案1】:

    据我所知,md-select 正在开发中,但尚不可用。但您可以在本期跟踪当前进展:angular2-material issue 118

    【讨论】:

      【解决方案2】:

      这里是

      //Your component
      
      import {Component} from '@angular/core';
      
      
      @Component({
        selector: 'select-form-example',
        templateUrl: 'select-form-example.html',
      })
      export class SelectFormExample {
        selectedValue: string;
      
        foods = [
          {value: 'steak-0', viewValue: 'Steak'},
          {value: 'pizza-1', viewValue: 'Pizza'},
          {value: 'tacos-2', viewValue: 'Tacos'}
        ];
      }
      <form>
        <md-select placeholder="Favorite food" [(ngModel)]="selectedValue" name="food">
          <md-option *ngFor="let food of foods" [value]="food.value">
            {{food.viewValue}}
          </md-option>
        </md-select>
      
        <p> Selected value: {{selectedValue}} </p>
      </form>

      【讨论】:

        猜你喜欢
        • 2017-09-28
        • 2017-02-02
        • 2016-03-03
        • 1970-01-01
        • 2018-03-03
        • 2017-01-27
        • 1970-01-01
        • 2017-11-06
        • 2016-12-12
        相关资源
        最近更新 更多