简体   繁体   中英

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};

Bind value in model to get selected.

Try like this

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM