为什么 md-select 没有填充 angular?
why md-select does not get populated with angular?
我在我的应用程序中使用 material select,当我使用 bootstrap 时它可以正常工作 select。这里有什么问题?这是代码,
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
;
widget 是任意数组。
您需要将 widget
替换为 widget[0]
这是更新的plunker。 http://plnkr.co/edit/MxfwsFafIky2L7VZguAE?p=preview
您错过了在两个地方引用小部件索引 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>
我在我的应用程序中使用 material select,当我使用 bootstrap 时它可以正常工作 select。这里有什么问题?这是代码,
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
;
widget 是任意数组。
您需要将 widget
替换为 widget[0]
这是更新的plunker。 http://plnkr.co/edit/MxfwsFafIky2L7VZguAE?p=preview
您错过了在两个地方引用小部件索引 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>