1
我有一個用戶列表,我在列表中做了一個ng-repeat,如下所示。
我傳遞用戶的ID模型,但是,我想同樣的選擇的用戶的電子郵件傳遞到另一種模式,如:angularjs將選定的ng-repeat選項的另一個屬性傳遞給另一個模型
<span>The selected user's email is : {{myModel.email}} </span>
,但我什麼也沒得到。失敗!我應該怎麼做才能解決它?
<div class="form-group">
<ui-select ng-model="myModel.user" name="user" theme="selectize" required ng-change="myModel.email = user.email" title="Choose user">
<ui-select-match placeholder="Select user">{{$select.selected.firstName}} {{$select.selected.lastName}}
</ui-select-match>
<ui-select-choices repeat="user.id as user in userList | userFilter:$select.search">
<div ng-bind-html="user.firstName + ' ' + user.lastName | highlight: $select.search"></div>
<small>
email: {{user.email}}
</small>
</ui-select-choices>
</ui-select>
<br/>
<span>The selected user's email is : {{myModel.email}} </span>
</div>
這裏是控制器:
$firebaseArray(MyDataBase.ref('users').orderByKey()).$loaded().then(function (res) {
for (var i = 0; i < res.length; i++) {
if (res[i].$id !== current.uid) {
$scope.userList.push({
id: res[i].$id,
firstName: res[i].firstName,
lastName: res[i].lastName,
email: res[i].email
});
} else {
defaultUser = res[i];
}
}
});