当以编程方式更改模型时调用 Angular 的 ng-change 时出现问题。
$scope.sendMessage = function() {
$scope.message = "Message sent";
}
$scope.confirmed = true;
$scope.mySelectBox = $scope.selects[1];
<select ng-model="mySelectBox"
ng-options="item.name for item in selects track by item.name"
ng-change="sendMessage()">
</select>
这是代码示例:http ://plnkr.co/edit/R4MO86ihMrauHXhpCMxi?p=preview
消息应该为空,因为sendMessage不应该被调用。模型以编程方式更改。