Html 通过重复从select元素多次调用onselect
Im使用HTMLSelect元素显示实体字段,该字段中包含枚举值 在页面中,我有多个实体字段,因此有多个select元素 通过在我的表格行的ng repeat中创建一个select,我使用角度ng repeat来显示每个字段。我想在从任何下拉列表中选择一个项目时捕获“onselect”事件,问题是,每当用户在一个下拉列表中选择一个值时,页面上的所有下拉列表都会触发该事件 我的html:Html 通过重复从select元素多次调用onselect,html,select,angularjs,onselect,ng-repeat,Html,Select,Angularjs,Onselect,Ng Repeat,Im使用HTMLSelect元素显示实体字段,该字段中包含枚举值 在页面中,我有多个实体字段,因此有多个select元素 通过在我的表格行的ng repeat中创建一个select,我使用角度ng repeat来显示每个字段。我想在从任何下拉列表中选择一个项目时捕获“onselect”事件,问题是,每当用户在一个下拉列表中选择一个值时,页面上的所有下拉列表都会触发该事件 我的html: <div ng-app> <div ng:controller="TodoCtrl">
<div ng-app>
<div ng:controller="TodoCtrl">
<table>
<tr ng-repeat="prop in customForm">
<td>{{prop.legend}}</td>
<td>
<select ng-name="prop.name" ng-model="entity[prop.name]"
ng-options="val as val for val in prop.enumeratedValues"
onselect="{{fireSelectEvent(prop.name)}}"></select>
</td>
</tr>
<tr><td>Calls Made</td></tr>
<tr ng-repeat="call in callLog">
<td>{{call}}</td>
</tr>
</table>
</div>
</div>
我的小提琴:
祝你好运。我们都指望你。onselect的
属性是什么?您会看到fireSelectEvent
多次触发,因为您已经使用绑定了onselect
属性
我猜您想做的是:ng change=“fireSelectEvent(prop.name)”
你最新的小提琴:
//'use strict';
function TodoCtrl($scope) {
$scope.customForm =
[
{name:"aval", legend: "A Value", enumeratedValues: ["1","2","3"], editable: true},
{name:"bval", legend: "B Value", enumeratedValues: ["4","5","6"], editable: true},
{name:"cval", legend: "C Value", enumeratedValues: ["7","8","9"], editable: true}
];
$scope.entity = {};
$scope.callLog = [];
$scope.fireSelectEvent = function( propName )
{
console.log("Prop=" + propName + " value=" + $scope.entity[propName]);
$scope.callLog.push( propName );
}
}