Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 角度Js:选择框设置选定值_Angularjs_Angularjs Directive_Selected - Fatal编程技术网

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