我有以下内容:
<select data-ng-model="selectedTestAccount" data-ng-options="item.Id as item.Name for item in testAccounts">
<option value="">Select Account</option>
</select>
有人向我建议,我可以观察这个选择的值是否会随着以下内容发生变化:
$scope.$watch('testAccounts', function(){
/* get updated values and update other select "model" on success*/
alert("hello");
});
但这似乎不起作用。一方面,它会在选择出现在屏幕上并且在用户选择任何内容之前立即发出警报。我说我应该注意 selectedTestAccount 的变化是否正确?最后还有一个问题。如何在警报框中显示 selectedTestAccount 的值?