将 select 与对象数组绑定,并在项目从 select 标签 select 编辑时显示详细信息

Bind select with array of objects and display details when item is selected from select tag

我有一个数组

$scope.items= [
{ name: "Name1", email: "email1", password: "pas1" },
{ name: "Name2", email: "email2", password: "pas2" }
];

我想在 select 标签中显示电子邮件值。我正在使用以下代码,但它不起作用。我想要第一项 'Select' :

<select id="idItem">
<option value="-1" selected="selected">Select</option>
<option ng-repeat="o.email as o.email for o in items" value="{{o.email}}"> {{o.email}}
</option>
</select>

用户还可以 select 多个项目。当用户 select 从 select 邮箱发送多封电子邮件时,消息框应弹出显示 selected 用户的名称和密码。

<select id="idItem" >
<option value="-1" selected="selected">Select</option>
<option ng-repeat="item in items" value="{{item.email}}"> {{item.email}}
</option>
</select>

我认为这可行....如果不行请下次提供你的 plunkerurl

如果您已经有一个包含所有项目的 json 对象,我更愿意使用 ng-options。此外,您需要将 multiple="true" 用于 multi-select 和 ng-model 来存储 selected 结果

<select id="idItem" multiple="true" ng-model="selectedItems"
        ng-options="item.email for item in items">
</select>

然后您可以创建一个显示 selectedItems 的消息框