我只是想知道在Angular应用程序中从服务器查看模型数据的最佳做法是什么?
例如,在我的控制器中,我从服务器(使用自定义ngResource
服务)获取模型,然后我需要在我的应用程序的客户端创建某种不同的模型:
customApiService.query({ url: 'items' }, function (res) {
// made it like this and do everything in partials with "ng-repeat"?!
$scope.items = res;
// but i need to model server data on client...
angular.forEach(res, function (key, i) {
$scope.viewModel = {
description: key.anotherNameField // e.g. different third-party services return description under different names
};
});
});