我有一个表单可以从用户那里获取所有数据字段,但是当我试图显示它时,只有json文件数据显示,我无法获取我推送到客户机数组中要显示的数据,我确信数据已添加到客户机数组中,因为我可以在控制台中记录它。
html视图:
<div ng-controller="adminCtrl" class="listClients">
<h1>Liste des clients :</h1>
<ul>
<li ng-repeat="client in clients">
<h3>{{client.numClient}} - {{client.rue}}</h3>
</li>
</ul>
</div>
app.js
myApp.controller('adminCtrl', ['$scope', '$http', '$location',function($scope, $http, $location){
//get clients in arr clients
$http.get("data/clients.json").then(function(response){
$scope.clients = response.data;
}); // clients is an array containing all clients from clients.json
//add newclient
$scope.addClient = function(){
$scope.clients.push ({
numClient: parseInt($scope.newclient.numClient),
rue: $scope.newclient.rue,
numRue: parseInt($scope.newclient.numRue),
codePostal: parseInt($scope.newclient.codePostal),
localite: $scope.newclient.localite,
available: true
});
$scope.newclient.numClient = "";
$scope.newclient.rue = "";
$scope.newclient.numRue = "";
$scope.newclient.codePostal = "";
$scope.newclient.localite = "";
};
}]);
暂无答案!
目前还没有任何答案,快来回答吧!