Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In AngularJS, is there a way to set the size of a <select> element with scope value?

Tags:

angularjs

Using AngularJS, I'm setting HTML form elements with some data inside $scope.

<select  style='width:300px' size='10' ng-model='selected' ng-options='k as v for (k,v) in options' />

In this example, size is set to 10. But I would like to set it according to some value inside the $scope. Is there a way?

like image 924
serdar Avatar asked Feb 27 '14 15:02

serdar


1 Answers

Use ng-size='10' instead of size

That look like

<select  style='width:300px' ng-size={{size}} ng-model='selected' ng-options='k as v for (k,v) in options' />

js code

$scope.size=10;

Edit

As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months.

Please try the newest versions of Angular (1.0.8 and 1.2.0-rc.1), and if the issue persists, comment below so we can discuss it.

New Edit

or You can do this way

data-ng-attr-size="{{some interpolated expression}}"

Demo : http://plnkr.co/edit/a1xLPGn2YeW0WavH2auD?p=preview

Thanks!

like image 166
Ramesh Rajendran Avatar answered Oct 05 '22 22:10

Ramesh Rajendran