$scope.changeStores = function () {
operateTableData
.nretrievePageDate('SyncCommodity', {
brandId: $scope.center.brand.Id,
settingId: 0
})
.then(
function (data) {
/* console.log(data);*/
$scope.center.letters = data.Data;
$scope.center.selectedLetter = 0;
$scope.stores = [];
angular.forEach(data.Data, function (v, k) {
$scope.stores = $scope.stores.concat(v.Stores);
});
$scope.LetterStores = $scope.stores;
},
function (error) {
}
);
};
$scope.changeStoresByLetter = function () {
if ($scope.center.selectedLetter == 0) {
$scope.LetterStores = $scope.stores;
} else {
$scope.LetterStores = $scope.center.selectedLetter;
}
};
这些代码是AngularJS的控制器中的函数,主要用于处理用户的交互和数据展示。其中,$scope.changeStores函数会通过调用operateTableData服务中的方法从服务器获取数据,并将获取到的数据存储到$scope对象中的center属性和letters属性中。同时,它还会将获取到的数据中的Stores属性合并到$scope.stores数组中,以便后续的操作。
$scope.changeStoresByLetter函数则用于根据用户选择的字母过滤店铺。如果用户选择了“全部”,则会将所有店铺展示出来;如果选择了具体的字母,则只展示该字母对应的店铺。具体实现是通过判断$scope.center.selectedLetter属性来过滤数据,如果等于0则展示所有店铺,否则根据字母过滤展示店铺。
仅供参考