Angularjs 角度Js:选择框设置选定值
我有一个选择框Angularjs 角度Js:选择框设置选定值,angularjs,angularjs-directive,selected,Angularjs,Angularjs Directive,Selected,我有一个选择框 <select populate-details ng-model="properties.maxRetries.type" ng-options="value as text for (text, value) in presentation.sources.maxR_Source"></select> 我想将选项“分钟”设置为初始选择。我怎么能那样呢 请帮忙, 谢谢。在控制器中,设置$scope.properties.maxRetries.type
<select populate-details ng-model="properties.maxRetries.type" ng-options="value as text for (text, value) in presentation.sources.maxR_Source"></select>
我想将选项“分钟”设置为初始选择。我怎么能那样呢
请帮忙,
谢谢。在控制器中,设置
$scope.properties.maxRetries.type='Minutes'
。然后,您的ng模型将拾取该值并将其应用于选项
angular.module("test.directives").directive("populateDetails", function() {
return {
link: function(scope, elem, attrs, ctrl) {
scope.presentation.sources.maxR_Source = {
"Hours": "4",
"Minutes": "5",
"Seconds": "6"
};
}
};
});