Reputation: 1655
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
Reputation: 25352
Bind value in model to get selected.
Try like this
$scope.rule.condition=$scope.conditions[0].value;
Upvotes: 1