Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何逐个显示已提取的记录_Javascript_Html_Angularjs - Fatal编程技术网

Javascript 如何逐个显示已提取的记录

Javascript 如何逐个显示已提取的记录,javascript,html,angularjs,Javascript,Html,Angularjs,我在angular js、javscript和HTML中工作。我可以从数据库中获取客户姓名及其详细信息的列表,但我想在按下“下一步”按钮时逐个显示这些记录。你能告诉我怎么做吗 提前感谢。您按下某个按钮,将触发某个事件,您将点击某个API,响应将显示在页面上。如果是,让我们说“打开”按钮,然后单击“显示数据”功能触发 App.controller('CustomerCtrl',['$scope',function($scope){ $scope.ShowData = CustomerSer

我在angular js、javscript和HTML中工作。我可以从数据库中获取客户姓名及其详细信息的列表,但我想在按下“下一步”按钮时逐个显示这些记录。你能告诉我怎么做吗


提前感谢。

您按下某个按钮,将触发某个事件,您将点击某个API,响应将显示在页面上。如果是,让我们说“打开”按钮,然后单击“显示数据”功能触发

App.controller('CustomerCtrl',['$scope',function($scope){
   $scope.ShowData =  CustomerService.Names().then(function(data){
    $scope.customers =  data
   })
}])
在Html中

<div ng-controller="CustomerCtrl">
 <div ng-repeat="customer in customers">
   <h3 ng-bind="customer.name"></h3>
 </div> 
</div>

您可以通过使用ng repeat和limito filter来解决上述问题。此处$scope.customers包含JSON数组。limito还可以使用变量i进行控制

函数MyCtrl($scope){
$scope.i=1;
$scope.customers=[{
“名字”:“约翰”,
“地点”:“美国”,
“编号”:“78437375”
}, {
“名字”:“安娜”,
“地点”:“亚洲”,
“编号”:“5464656”
}, {
“名字”:“彼得”,
“地点”:“欧洲”,
“编号”:“24353535”
}];
$scope.showMoreCustomers=function()
{
$scope.i++;
}
$scope.showlescscustomers=function()
{
$scope.i--;
}
}

+
-
<div ng-controller="CustomerCtrl">
  <button value="Next" ng-click="next()">
  <div>
    <h3>{{name}}</h3>
  </div> 
</div>
App.controller('CustomerCtrl',['$scope',function($scope){    
$scope.ShowData =  CustomerService.Names().then(function(data){    
$scope.customers =  data;       

  })    
var cnt=0;    
$scope.next=function(){
   $scope.name=$scope.customers[cnt].name;      
  cnt++;
}

}])