【问题标题】:angularjs cant make initial value to chained dropdownangularjs无法为链式下拉列表设置初始值
【发布时间】:2013-11-19 14:38:07
【问题描述】:

我设法制作了一个链式下拉列表,但我无法让它们具有初始值。我正在做这样的事情:

<select ng-model="check" ng-options="check.name for check in checks"></select>
              <select ng-show="check.params" ng-model="parameter" ng-options="p.name for p in check.params"></select>

这里是单次检查的示例:

 [0] => Array
        (
            [id] => 1
            [name] => existing_client
            [params] => Array
                (
                    [0] => Array
                        (
                            [id] => 3
                            [name] => IsEnabled
                            [type] => boolean
                            [check_id] => 1
                        )

                    [1] => Array
                        (
                            [id] => 18
                            [name] => country
                            [type] => country_comparison
                            [check_id] => 1
                        )

                    [2] => Array
                        (
                            [id] => 19
                            [name] => affiliate_id
                            [type] => string_comparison
                            [check_id] => 1
                        )

                    [3] => Array
                        (
                            [id] => 14
                            [name] => created_at
                            [type] => date
                            [check_id] => 1
                        )

                    [4] => Array
                        (
                            [id] => 15
                            [name] => muid
                            [type] => string_comparison
                            [check_id] => 1
                        )

                    [5] => Array
                        (
                            [id] => 20
                            [name] => region
                            [type] => string_comparison
                            [check_id] => 1
                        )

                    [6] => Array
                        (
                            [id] => 24
                            [name] => created_at_interval
                            [type] => interval
                            [check_id] => 1
                        )

                )

        )

【问题讨论】:

  • 如果您可以在 jsfiddle 或 plunker 中重新创建您的概念,这可以帮助我们重新创建问题并解决它:)

标签: angularjs chained


【解决方案1】:

&lt;select&gt; 的 ng-model 是 checked。

您需要过滤您的数组以找到要设置为 $scope.checked 的项目,或使用任何逻辑来确定此值

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 2021-01-11
    • 1970-01-01
    • 2018-08-07
    • 2014-07-28
    • 2011-03-19
    • 2015-08-15
    相关资源
    最近更新 更多