使用Angular JS调用服务器的主细节
我是Angular JS的新手,我需要从许多表中拨打大师的细节。
我在其他4个SQL表中有一个主SQL表和儿童数据。我需要在单页中显示所有数据。
我是否应该使用单个AJAX调用来从服务器检索所有数据,或者我应该单独调用以获取每个数据。我正在考虑在Angular JS中使用$ Q.all()
。我开始使用第二种方式。希望现在很好
$scope.p1 = $http.get('/p1', {cache: false});
$scope.p2 = $http.get('/p2', {'cache': false});
$q.all([$scope.p1, $scope.p2]).then(function(values) {
$scope.p1= values[0];
$scope.p2 = values[1];
});
,现在我可以在模板中使用NG重复来迭代每个变量并显示数据。如果我错了,请纠正我。
I am new to Angular JS and I need to call Master-child details from many tables.
I have one main SQl table and child data in 4 other SQL tables. I need to display all data in single page.
Should I use single ajax call to retrieve all data from server or Should I make separate calls to get each data. I am thinking of using $q.all()
in angular js. I started to use Second way . Hope it is fine
$scope.p1 = $http.get('/p1', {cache: false});
$scope.p2 = $http.get('/p2', {'cache': false});
$q.all([$scope.p1, $scope.p2]).then(function(values) {
$scope.p1= values[0];
$scope.p2 = values[1];
});
Now I can use ng-repeat in my template to iterate each variable and display data. pls correct me if I am wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论