【问题标题】:Angular Js: Select box set selected valueAngular Js:选择框设置选定值
【发布时间】:2014-11-19 04:11:49
【问题描述】:

我有一个选择框,

 <select populate-details ng-model="properties.maxRetries.type" ng-options="value as text for (text, value) in presentation.sources.maxR_Source"></select>

关于选择框的填充指令:

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

我想将选项“分钟”设置为最初选择的状态。怎么办?

请帮忙, 谢谢。

【问题讨论】:

    标签: angularjs angularjs-directive selected


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2012-09-08
      • 2018-09-12
      • 2018-10-22
      • 1970-01-01
      • 2015-03-21
      • 1970-01-01
      • 1970-01-01
      • 2014-10-18
      • 1970-01-01
      相关资源
      最近更新 更多