[英]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.