角度Js:选择框设置选定值

时间:2014-11-19 04:11:50

标签: 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>
填写selectbox的

指令:

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

我想最初选择“Minutes”选项。我该怎么做?

请帮忙, 感谢。

1 个答案:

答案 0 :(得分:0)

在控制器中,设置$scope.properties.maxRetries.type = 'Minutes'。然后你的ng-model将获取值并将其应用于选项。