problema no angularjs
não estou a conseguir por a mostrar os dados de uma tabela
<!DOCTYPE html>
<html ng-app="myApp" lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<meta name="description" content="Game">
<meta name="author" content="Pedro Alves">
<link rel="icon" href="../favicon.ico">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="dist/js/mapa.js"></script>
<title>Game</title>
<!-- Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<link href="dist/css/menu.css" rel="stylesheet" type="text/css">
<script src="dist/js/modernizr.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="dist/js/ui-bootstrap-tpls-0.10.0.min.js"></script>
<script type="text/javascript" src="dist/js/shCore.js"></script>
<script type="text/javascript" src="dist/js/shBrushXml.js"></script>
<script type="text/javascript" src="dist/js/shBrushJScript.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="dist/js/ie-emulation-modes-warning.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php
require_once('configurations/Database.php');
?>
<div ng-controller="customersCrtl" class="container" align="left" style="width:100%;height:800px;">
<div class="row">
<div class="col-md-2">PageSize:
<div class="input-group number-spinner">
<span class="input-group-btn data-dwn">
<button class="btn btn-default btn-info" data-dir="dwn"><span class="glyphicon glyphicon-minus"></span></button>
</span>
<input type="text" class="form-control text-center" style="width:50px" value="1" min="1" max="20">
<span class="input-group-btn data-up">
<button class="btn btn-default btn-info" data-dir="up"><span class="glyphicon glyphicon-plus"></span></button>
</span>
</div>
<!--select ng-model="entryLimit" class="form-control">
<option>5</option>
<option>10</option>
<option>20</option>
<option>50</option>
<option>100</option>
</select-->
</div>
<div class="col-md-3" >Filter:
<!--input type="text" ng-model="search" ng-change="filter()" placeholder="Filter" class="form-control" /-->
</div>
<div class="col-md-4">
<h5>Filtered {{ filtered.length }} of {{ totalItems}} total Empresas</h5>
</div>
</div>
<br/>
<div class="row">
<div class="col-md-12" ng-show="filteredItems > 0">
<table class="table table-striped table-bordered">
<thead >
<th>Nome</th>
<th>Descricao</th>
<th>Quantidade</th>
<th>Preco Sem Iva</th>
<th>Descontos</th>
<th>IVA</th>
<th>Valor do Desconto</th>
<th>Valor do IVA</th>
<th>Preço TOTAL</th>
<th>Ver</th>
</thead>
<tbody ng-init="get_product()">
<tr ng-repeat="data in filtered = (list | filter:search | orderBy : predicate :reverse) | startFrom:(currentPage-1)*entryLimit | limitTo:entryLimit">
</tr>
<tr>
<td style="color:#000000">{{data.nome}}</td>
<!--td>{{data.descricao}}</td>
<td>{{data.quantidade}}</td>
<td>{{data.precosiva}}</td>
<td>{{data.descontos}}</td>
<td>{{data.iva}}</td>
<td>{{data.valordesc}}</td>
<td>{{data.valoriva}}</td>
<td>{{data.precototal}}</td-->
<td> <button class="btn" ng-click="prod_espiar(data.id)">
<span class="glyphicon glyphicon-pencil"></span> Selecionar
</button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="col-md-12" ng-show="filteredItems == 0">
<div class="col-md-12">
<h4>Nenhum projecto Adecionado</h4>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
<!-- Just to make our placeholder images work. Don't actually copy the next line! -->
<script src="dist/js/holder.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="dist/js/ie10-viewport-bug-workaround.js"></script>
<script src="dist/js/bootstrapValidator.js"></script>
<script src="dist/js/bootstrapValidator.min.js"></script>
</body>
</html>
require_once ('configurations/Database.php');//Incluir definicoes de acesso a BD
// algumas funcoes
switch($_GET['action']) {
// case 'add_product' :
// add_product();
// break;
case 'get_product' :
get_product();
break;
/* case 'edit_product' :
edit_product();
break;
*/
///case 'delete_product' :
// delete_product();
// break;
// case 'update_product' :
// update_product();
// break;
}
function get_product() {
$link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if (!$link) {
die('Falha de ligacao a BD: ' . mysql_error());
}
/*$qry="select distinct c.nome,c.descricao,c.texto,c.categoria from projecto c order by c.idprojecto";
$result = $link -> query($qry);
$arr = array();
if($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
$arr[] = $row;
}
}else die("ERRO");
JSON-encode the response
$json_response = json_encode($arr);// # Return the response
echo $json_response;
*/
//$qry="select distinct c.nome,c.descricao,c.texto,c.categoria from projecto c order by c.idprojecto";
//$qry ="SELECT nome FROM servicos";
// where id_empresa='" .$index. "'
// $qry ="SELECT nome,descricao,quantidade,precosiva,descontos,iva,valordesc,valoriva,precototal FROM servicos";
$qry ="SELECT usermame FROM users ";
$result = $link -> query($qry);
$data = array();
if ($result) {
while($rows = $result->fetch_assoc())
{
$data[] = array(
"username" => $rows['username']
/*"descricao" => $rows['descricao'],
"quantidade" => $rows['quantidade'],
"precosiva" => $rows['precosiva'],
"descontos" => $rows['descontos'],
"iva" => $rows['iva'],
"valordesc" => $rows['valordesc'],
"valoriva" => $rows['valoriva'],
"precototal" => $rows['precototal']
*/
);
}
print_r(json_encode($data));
return json_encode($data);
}else
die("ERRO". mysqli_error());
}/*
function edit_product() {
$data = json_decode(file_get_contents("php://input"));
$index = $data->ola;
$link = new mysqli(DB_HOST, DB_USER, DB_PASSWORD, DB_DATABASE);
if (!$link) {
die('Falha de ligacao a BD: ' . mysql_error());
}
$qry = "SELECT * FROM projecto WHERE idprojecto='" .$index. "'";
$result = $link ->query($qry);
$data = array();
if ($result) {
while($rows = $result->fetch_assoc())
{
$data[] = array(
"idprojecto" => $rows['idprojecto'],
"nome" => $rows['nome'],
"descricao" => $rows['descricao']
// "categoria" => $rows['categoria']
// "texto" => $rows['texto'],
);
}
print_r(json_encode($data));
return json_encode($data);
}else die("ERRO");
}
*/
?>
var app = angular.module('myApp', ['ui.bootstrap']);
app.filter('startFrom', function() {
return function(input, start) {
if (input) {
start = +start;
//parse to int
return input.slice(start);
}
return [];
}
});
app.controller('customersCrtl', function($scope, $http, $timeout) {
$scope.get_product = function() {
$http.get('app/mapa.php?action=get_product').success(function(data) {
//$scope.producst_detail = data;
$scope.list = data;
$scope.currentPage = 1;
//current page
$scope.entryLimit = 5;
//max no of items to display in a page
$scope.filteredItems = $scope.list.length;
//Initially for no filter
$scope.totalItems = $scope.list.length;
});
}
$http.get('app/mapa.php').success(function(data){
$scope.list = data;
$scope.currentPage = 1; //current page
$scope.entryLimit = 5; //max no of items to display in a page
$scope.filteredItems = $scope.list.length; //Initially for no filter
$scope.totalItems = $scope.list.length;
});
$scope.setPage = function(pageNo) {
$scope.currentPage = pageNo;
};
$scope.filter = function() {
$timeout(function() {
$scope.filteredItems = $scope.filtered.length;
}, 10);
};
$scope.sort_by = function(predicate) {
$scope.predicate = predicate;
$scope.reverse = !$scope.reverse;
};
/* $scope.prod_espiar = function(index) {
$scope.update_prod = true;
$scope.add_prod = false;
$http.post('app/mapa.php?action=edit_product', {
'ola' : index
}).success(function(data, status, headers, config) {
//alert(data[0]["prod_name"]);
// $scope = data[0]["nome"];
$scope.nome = data[0]["Nome"];
//$scope.username = data[0]["username"];
// $scope.Alianca = data[0]["Alianca"];
}).error(function(data, status, headers, config) {
});
}
$scope.prod_escreve = function(index) {
$scope.update_prod = true;
$scope.add_prod = false;
$http.post('../app/mapa.php?action=edit_product', {
'ola' : index
}).success(function(data, status, headers, config) {
//alert(data[0]["prod_name"]);
$scope.contintente = data[0]["continente"];
$scope.nome = data[0]["Nome"];
$scope.username = data[0]["username"];
// $scope.Alianca = data[0]["Alianca"];
}).error(function(data, status, headers, config) {
});
}
$scope.prod_amizade = function(index) {
$scope.update_prod = true;
$scope.add_prod = false;
$http.post('../app/mapa.php?action=edit_product', {
'ola' : index
}).success(function(data, status, headers, config) {
//alert(data[0]["prod_name"]);
$scope.contintente = data[0]["continente"];
$scope.nome = data[0]["Nome"];
$scope.username = data[0]["username"];
// $scope.Alianca = data[0]["Alianca"];
}).error(function(data, status, headers, config) {
});
}
$scope.prod_Ataque = function(index) {
$scope.update_prod = true;
$scope.add_prod = false;
$http.post('../app/mapa.php?action=edit_product', {
'ola' : index
}).success(function(data, status, headers, config) {
//alert(data[0]["prod_name"]);
$scope.contintente = data[0]["continente"];
$scope.nome = data[0]["Nome"];
$scope.username = data[0]["username"];
// $scope.Alianca = data[0]["Alianca"];
}).error(function(data, status, headers, config) {
});
}*/
});
da me o seguintes erros
Error: [ngRepeat:dupes] [http://errors.angularjs.org/1.3.14/ngRepeat/dupes?p0=data in filtered %3D (list | filter%3Asearch | orderBy %3A predicate %3Areverse) | startFrom%3A(currentPage-1)*entryLimit | limitTo%3AentryLimit&p1=string%3A &p2=](http://errors.angularjs.org/1.3.14/ngRepeat/dupes?p0=data%20in%20filtered%20%3D%20(list%20%7C%20filter%3Asearch%20%7C%20orderBy%20%3A%20predicate%20%3Areverse)%20%7C%20startFrom%3A(currentPage-1)*entryLimit%20%7C%20limitTo%3AentryLimit&p1=string%3A%0A&p2=%0A)
at Anonymous function (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:232:446)
at Anonymous function (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:122:63)
at l.prototype.$digest (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:123:136)
at l.prototype.$apply (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:126:56)
at l (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:81:158)
at S (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:85:301)
at D.onload (http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js:86:315)
angular.js (11607,11)Discussão (1)
Carregando comentários...