为什么我的ng-materials“select”元素的功能与我的HTML5元素不同?

时间:2016-03-16 15:44:00

标签: javascript angularjs angular-material

我试图使用ng-materials ui-components中的md-input和md-option元素。

作为ng-materials对象,它不起作用:

<md-input-container>
    <md-select ng-model="forcast.selectedCompound">
       <md-option ng-value="compound._id" ng-repeat="compound in forcast.compounds" >
              {{compound.compound_number}}
        </md-option>
    </md-select>
</md-input-container>

使用常规的html 5组件确实有效:

<md-input-container>
    <select ng-model="forcast.selectedCompound">
       <option value="{{compound._id}}" ng-repeat="compound in forcast.compounds" >
              {{compound.compound_number}}
        </option>
    </select>
</md-input-container>

因为html5元素有用,我确信我的ng-materials标记有问题?

1 个答案:

答案 0 :(得分:1)

您应该使用value中的md-option属性而不是ng-value {{ }}。查看select的官方文档。

<md-input-container>
<md-select ng-model="forcast.selectedCompound">
   <md-option value="{{compound._id}}" ng-repeat="compound in forcast.compounds" >
          {{compound.compound_number}}
    </md-option>
</md-select>

工作示例。 http://codepen.io/next1/pen/yOgYVP