我在使用Angular js激活我的select2 on-change事件时遇到了问题.
这是我的HTML:
<select ui-select2="{allowClear:true}" data-placeholder="Select a Department" ng-change="DoSomething()" class="input-max" ng-model="l.DepartmentID"> <option value=""></option> <option ng-repeat="d in l.LineLookups.Departments" value="{{d.DepartmentID}}">{{d.Type}}</option> </select>
当选择下拉列表更改时,更改事件不会触发.这是我的控制器中的事件处理程序:
$scope.DoSomething = function () { alert('here'); ... }
另外通过观看ng-model:
原文链接:https://www.f2er.com/angularjs/143508.html在视图中:
<select ui-select2="{allowClear:true}" data-placeholder="Select a Department" class="input-max" ng-model="l.DepartmentID"> <option value=""></option> <option ng-repeat="d in l.LineLookups.Departments" value="{{d.DepartmentID}}">{{d.Type}}</option> </select>
在控制器中:
$scope.$watch('l.DepartmentID',function (newVal,oldVal) { if (oldVal == newVal) return; alert('here'); },true);