为什么md-select没有填充角度?

时间:2015-02-26 10:07:38

标签: javascript html angularjs material-design

我在我的应用程序中使用材质选择,当我使用bootstrap时,它使用正常选择。这是什么问题?这是代码,

HTML:

<md-select ng-model="widget.chartConfig.options.chart.type" >
        <md-option ng-value="t.title" data-ng-repeat="t in widget.chartTypes">{{ t.title }}</md-option>
</md-select>

App.js:

var app = angular.module('DemoApp', ['ngMaterial']);    
app.controller('MainCtrl', function($scope) {
    $scope.widget = [];
    $scope.widget.push(    
  {
     chartTypes:[
  {"id": "line", "title": "Line"},
  {"id": "spline", "title": "Smooth line"},
  {"id": "area", "title": "Area"},
  {"id": "areaspline", "title": "Smooth area"},
  {"id": "column", "title": "Column"},
  {"id": "bar", "title": "Bar"},
  {"id": "pie", "title": "Pie"},
  {"id": "scatter", "title": "Scatter"}
  ],
   chartConfig : {
    options: {
      chart: {         
        type:  "bar"
      }
  }
  }
  }
  );
});

这是Plunker;

2 个答案:

答案 0 :(得分:2)

widget是任何数组。 您需要将widget替换为widget[0] 这是更新的plunker。 http://plnkr.co/edit/MxfwsFafIky2L7VZguAE?p=preview

答案 1 :(得分:1)

您错过了在两个地方引用小部件索引widget ti widget[0]

<强> HTML

<md-select ng-model="widget[0].chartConfig.options.chart.type" >
        <md-option ng-value="t.title" data-ng-repeat="t in widget[0].chartTypes">{{ t.title }}</md-option>
</md-select>

Working Plukr

相关问题