控制选择元素内选项的宽度

时间:2018-10-30 13:36:31

标签: css angularjs

我有一个具有一定宽度的选择元素。我的问题是,关于输入长度,如何使用角度控制选项的宽度,以使它们与选择栏的宽度相同? 我正在使用ng-select设置选项。

myList.append([string,number])
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.names = ["Regular option", "Long option number 1", "Very very long option that doent mke sense"];
});

1 个答案:

答案 0 :(得分:0)

只需从选择元素(style="width: 180px")的样式中删除宽度

请参见以下代码段:

var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.names = ["Regular option", "Long option number 1", "Very very long option that doent mke sense"];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedName" ng-options="x for x in names">
</select>
</div>

<p>This example shows how to fill a dropdown list using the ng-options directive.</p>

</body>