AngularJS:为Select设置默认值(使用字符串' s列表)

时间:2016-01-25 12:36:19

标签: javascript angularjs angularjs-ng-repeat

我有一个包含字符串的数组(不是对象) 我使用AngularJS将它们绑定到Select控件 但是我遇到了设置默认设置的问题,因为我的数组包含字符串,而不是对象。我怎样才能以最正确的方式做到这一点?

这就是我得到的:

 var genders =["Male", "Female"];

<select data-ng-options="o.Name for o in genders track by o.Id"
 data-ng-model="selectedCustomer.Gender"
</select>

1 个答案:

答案 0 :(得分:1)

阅读DOCs,您只需将数组<select data-ng-options="o for o in genders" data-ng-model="selectedCustomer.Gender"> </select> 用作数据源即可。

trackexpr

您不需要 Dim SelectQuery As String = "Your Query" Dim WhereQuery As String = " WHERE (1=1)" ElseIf BOX_toDate.Text <> Nothing Then Name= WhereQuery & " AND TargetDate <= '" & Your value & "'" End If Dim con As New SqlConnection Dim cmd As New SqlCommand con = FunctionConnection() cmd.Connection = con cmd.CommandText = SelectQuery & WhereQuery cmd.CommandType = CommandType.Text

DEMO