嗨,我正在做一些在Angular Js中可能不太好的做法。
这是我的HTML代码:
<div class="row">
<div class="col-md-6">
<label for="dealership">Dealership:</label>
<select data-placeholder="Select Dealers" class="chosen" id="select1" chosen="SelectedDealerRank" style="width: 100%;" ng-model="SelectedDealerRank" ng-options="SelectedDealerRank as SelectedDealerRank.Dealership for SelectedDealerRank in AllDealers" ng-change="search();"></select></div>
<div class="col-md-6">
<label for="staff-member">Staff member:</label>
<!--<input type="text" ng-model="staffquery" style="height:25px; width:130px;" ng-change="searchallstaffmembers()" class="input-large search-query" placeholder="Search">-->
<select data-placeholder="Select Staff member" class="chosen" chosen="staffMemberRank" ng-model="staffMemberRank" ng-options="staffMemberRank as staffMemberRank.StaffMemberName for staffMemberRank in d2filteredstaffmembers" ng-change="" style="width: 100%;"></select>
</div>
</div>
关于ng-change搜索方法的被调用....
搜索方法
$scope.search = function () {
$scope.d2filteredstaffmembers = [];
for (var i = 0; i < $scope.filteredstaffmembers.length; i++) {
if (!$scope.SelectedDealerRank.DealerID.toString() || $scope.SelectedDealerRank.DealerID.toString() == 0) {
$scope.d2filteredstaffmembers.push($scope.filteredstaffmembers[i]);
}
else if ($scope.filteredstaffmembers[i].DealerID.toString() == $scope.SelectedDealerRank.DealerID.toString()) {
if ($scope.filteredstaffmembers[i] != null || $scope.filteredstaffmembers[i] != undefined) {
$scope.d2filteredstaffmembers.push($scope.filteredstaffmembers[i]);
}
}
}
$scope.currentPage = 0;
};
调用方法之后我将d2filteredstaff设置为新值的工作人员来源,但它没有显示任何更改。
任何想法?