Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

problem with angularjs

$
0
0
i create a model and i want show only the data is of one person but i only can show all data is table app.js 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/app.php?action=get_product').success(function(data) { //$scope.product_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/projectos.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/app.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_escreve = function(index) { $scope.update_prod = true; $scope.add_prod = false; $http.post('app/app.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/app.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/app.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) { }); } }); index.php <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#<?php echo $d?>" ><?php echo $m['nome'] ?></button> <div id="<?php echo $d?>" class="modal fade" role="dialog" > <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> </div> <div class="modal-body"> <div class="row"> <div class="col-sm-6"> <p> LogoTipo</p> <p><?php echo "Nif:", $m['nif'], " "; echo "CAE:", $m['CAE']; ?> </p> <p><?php echo "Nome da Empresa:", $m['nome']; ?> </p> <p><?php echo "Morada:", $m['morada']; ?> </p> <p><?php echo "Localidade:", $m['Localidade']; ?> </p> <p><?php echo "CodigoPostal:", $m['codigopostal']; ?> </p> <p><?php echo "Telefone:", $m['telefone'], " "; echo "Fax:", $m['fax'], " "; echo "Telemovel:", $m['telemovel']; ?> </p> <p><?php echo "Webmail:", $m['email']; ?></p> <?php foreach ($servicos->getcategorias($d)as $n): ?> <p><?php echo "Categorias:", $n['nome']; ?></p> <?php endforeach ?> </div> <div class="col-sm-6"> <?php foreach ($servicos->getactividades($d)as $g): ?> <p><?php echo "Actividades:", $g['nome']; ?></p> <?php endforeach ?> </div> <div ng-controller="customersCrtl"> <br/> <div class="row"> <div class="col-md-12" ng-show="filteredItems > 0"> <table class="table table-striped table-bordered"> <thead > <th style="visibility:collapse">ID&nbsp;</th> <th>Nome&nbsp;</th> <th>Descricao&nbsp;</th> <th>Quantidade&nbsp;</th> <th>Preco Sem Iva&nbsp;</th> <th>Descontos&nbsp;</th> <th>IVA&nbsp;</th> <th>Valor do Desconto&nbsp;</th> <th>Valor do IVA&nbsp;</th> <th>Preço TOTAL&nbsp;</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--> <td style="visibility:collapse">{{data.id}}</td> <td>{{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>&nbsp;&nbsp;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> </div> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Sair</button> </div> </div> </div> app.php <?php //Incluir definicoes de acesso a BD 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 id,nome,descricao,quantidade,precosiva,descontos,iva,valordesc,valoriva,precototal FROM servicos "; //$qry ="SELECT * FROM users"; $result = $link -> query($qry); $data = array(); if ($result) { while($rows = $result->fetch_assoc()) { $data[] = array( "id" => $rows['id'], "nome" => $rows['nome'], "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"); } */ ?>

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>