我想用一个<select>来使用ng-options来将数字整数值绑定到相应的选项列表。 在我的控制器中,我有这样的东西: myApp.controller('MyCtrl', function() { var self = this; var unitOptionsFromServer = { 2: "mA", 3: "A", 4: "mV", 5: "V", 6: "W", 7: "kW" }; self.unitsOptions = Object.keys(unitOptionsFromServer).map(function (key) { return { id: key, text: unitOptionsFromServer[key] }; }); self.selectedUnitOrdinal = 4; // Assume this value came from the server. }); HTML: <div ng-controller="MyCtrl as […]
基本上,我试图填充select框,但连接来自first_name列和last_name列的值。 我想做什么(不起作用): <select ng-model="buyers" ng-options="b.id as (b.first_name + " " + b.last_name) for b in buyers"></select> 什么工作: <select ng-model="buyers" ng-options="b.id as b.first_name for b in buyers"></select>