mm1975
mm1975

Reputation: 1655

Pre-Select of an option in a select not working

I use the following select. Currently, I get empty options in my select on start. To avoid these empty options in angularJS, I want to preselect the first option in the select. But It do not work. I get an 'Cannot read property 'conditions' of undefined'. Thank you for your tips!

HTML

<select ng-show="rule.field=='Cardiology'" ng-options="c.name as c.name for c in conditions" ng-model="rule.condition" class="form-control input-sm selectCondition"></select>

JS

scope.conditions = [{
        name : 'contains',
}, {
        name : 'doesn´t contain',
}];

$scope.conditions = {type : $scope.conditions[0].value};

Upvotes: 0

Views: 80

Answers (1)

Anik Islam Abhi
Anik Islam Abhi

Reputation: 25352

Bind value in model to get selected.

Try like this

$scope.rule.condition=$scope.conditions[0].value;

Upvotes: 1

Related Questions