Amit Jain
Amit Jain

Reputation: 129

AngularJS remove ng-options blank value

<select ng-model="form.priority" ng-options="priority.id as priority.value for priority in leadPriority"></select>

It is showing blank option by default. How can remove it ?

Upvotes: 0

Views: 541

Answers (3)

tech_ank
tech_ank

Reputation: 57

You can use ui-select which is more powerful version of select. You can find sample code for it here. You will need to include the js and css file from their library here.

Upvotes: 0

Arulkumar
Arulkumar

Reputation: 13237

You can set in the controller as,

$scope.form.priority = $scope.leadPriority[0].id;

Upvotes: 1

devesh singhal
devesh singhal

Reputation: 121

Use ng-init in options eg.

<select ng-model="form.priority" ng-options="priority.id as priority.value for priority in leadPriority" ng-init="form.priority = leadPriority[0].id"></select>

Upvotes: 1

Related Questions