[英]Angular ng-change event not working on first change?
仍在学习Angular的绳索,我有一种表格可以将学生从JSON返回值加载到选择的下拉列表中,我想根据学生ID将学校名称标签更改为列为学生学校的学校。 这是JSON的所有部分,并且正在起作用。 当我从下拉列表中选择学生时,什么都不会发生,但是如果我将选择更改回默认值,更改将起作用,并且标签现在具有预期的值。
在我的.ascx中
<select name="studentList" ng-model="student" ng-change="getStudent(student)" ng-options="s.StudentID as s.FirstName for s in cStudents | orderBy:'FirstName'">
<option value="">Choose Students...</option>
</select>
从控制器
angularVolunteerApp.controller('vAppController',
function vAppController($scope, $window) {
$scope.cStudents = $window.xStudents;
$scope.getStudent = function(xStudent) {
angular.forEach(xStudents, function (s) {
if (s.StudentId == xStudent) {
$scope.cSchoolName = s.SchoolName;
}
});
//$scope.cSchoolName = xStudent;
};
});
不知道这是否相关,但这适用于Sharepoint 2010中的Webpart
找到了您的主要问题,大写不能为null:
"CurrentStatus":null
不
"CurrentStatus":NULL
再加上变量命名不一致(框不一致),您将大受好评!
我为您修复了所有问题,并使其按照我认为您想要的做,请在此处查看:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.