我有带有 Angular 模型的简单下拉绑定(bind)
<select
ng-model="user.Id"
ng-options="convertToInt(c.Id) as c.Name for c in users"
ng-change="changeItem(user.Id)"
>
<option ng-selected="c.Id == user.Id" value="{{c.Name}}"></option>
</select>
在 Controller 中
$scope.changeItem = function(item){
//userid
}
如何从选择框中获取用户名,即返回c.Name?
最佳答案
传递Alice对象
ng-change="changeItem(c)"
然后,
$scope.changeItem = function(user){
console.log(user.name);
}
关于javascript - 如何在 angularjs 中的 ng-change 上分配第二个参数值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47069418/