javascript - Angular JS - ng-repeat error -
i not speak english well, apologize in advance misspellings
i creating user administration page on site developed angular js first time i'm using , can not figure out error
when click on list on index.html page sent page amministrazione2.html "should" start script data db , insert them in table, video show
<tbody> <!-- ngrepeat: prezzo in prezzi --> <t/ body>
instead of data
index.html, there list on left , evry item redirect .html page
<!doctype html> <html ng-app="sin..."> <head></head> <body> <div class="left_col scroll-view"> <div ng-include="'includes/header.html'"></div> </div> </div> <div ng-include="'includes/footer.html'"></div> </div> <script src="//code.angularjs.org/1.5.7/angular.js"></script> <script src="//code.angularjs.org/1.5.7/angular-route.js"></script> <script src="//code.angularjs.org/1.5.7/angular-cookies.js"></script> <script src="//code.angularjs.org/1.5.7/angular-messages.js"></script> <script src="js/app.js"></script> <script src="modules/amministrazione2/controllers.js"></script> </body> </html>
this header there element on left list
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu"> <div class="menu_section"> <li> <a href="#/amministrazione2"> <i class="fa fa-cog infospan"></i> amministrazione2 <span class="fa fa-chevron-right"></span></a> </li> </div> </div>
this file app.js there declaretions of angular module
'use strict'; // declare modules angular.module('ammi', []); angular.module('amministrazione', []); angular.module('authentication', []); angular.module('home', []); angular.module('fornitore', []); angular.module('cantiere', []); angular.module('prezziario', []); angular.module('calendar', []); angular.module('computo', []); angular.module('forniture', []); angular.module('listino', []); angular.module('sal', []); angular.module('sin...', [ 'amministrazione', 'ammi', 'authentication', 'home', 'fornitore', 'cantiere', 'prezziario', 'calendar', 'computo', 'forniture', 'listino', 'sal', 'ngroute', 'ngcookies', 'ngmessages', 'smart-table' ]) .config(['$routeprovider', function ($routeprovider) { $routeprovider .when('/amministrazione2', { controller: 'ammicontroller', templateurl: 'modules/amministrazione2/views/amministrazione2.html', hidemenus: true }) .when('/', { controller: 'homecontroller', templateurl: 'modules/home/views/home.html' }) .otherwise({ redirectto: '/login' }); }])
this php file search user information on db
<?php require_once '../includes/dbconnector.php'; $sql = "select a.id_utente, a.id_ruolo, a.nome, a.cognome, a.comune, a.indirizzo, a.cap, a.telefono1, a.telefono2, a.email, a.fax, a.note, a.user, a.password, a.calendario `sal_t_utente` order a.id_utente"; // use prepared statements, if not strictly required practice $stmt = $conn->prepare( $sql ); // execute query $stmt->execute(); // fetch results array $result = $stmt->fetchall( pdo::fetch_assoc ); $json = json_encode($result); return $json; } ?>
this angular controller i've create insert , modify data on table
'use strict'; angular.module('ammi').controller('ammicontroller', ['$scope', '$rootscope', '$location','$http', function ($scope, $rootscope, $location, $http) { $scope.selectedprezzo = ''; $scope.getprezzi = function() { $http.get('./api/amministrazione2/ricerca.php'). success(function(data) { $scope.prezzi = data; $scope.prezzicollection= data; }); }; $scope.editprezzo = function(prezzo) { $scope.selectedprezzo = prezzo; }; $scope.salvaprezzo = function(prezzo) { $http.post('./api/amministrazione2/aggiorna.php', { 'id_utente' : prezzo.id_utente, 'id_ruolo' : prezzo.id_ruolo, 'nome' : prezzo.nome, 'cognome' : prezzo.cognome, 'comune' : prezzo.comune, 'indirizzo' : prezzo.indirizzo, 'cap' : prezzo.cap, 'telefono1' : prezzo.telefono1, 'telefono2' : prezzo.telefono2, 'email' : prezzo.email, 'fax' : prezzo.fax, 'note' : prezzo.note, 'user' : prezzo.user, 'password' : prezzo.password, 'calendario' : prezzo.calendario } ).success(function (data, status, headers, config) { $scope.resetprezzo(); }); }; $scope.resetprezzo = function() { $scope.getprezzi(); $scope.selectedprezzo = ''; }; $scope.go = function ( path ) { $location.path( path ); }; }]);
this amministrazioni2.html show user information
<div ng-controller="getprezzi" > <table st-table="prezzi" st-safe-src="prezzicollection" class="bootstrap-table table table-hover table-striped table-bordered tableblueth"> <thead> <th>id utente</th> <th>id ruolo</th> <th>nome</th> <th>cognome</th> <th >comune</th> <th>indirizzo</th> <th>cap</th> <th >telefono 1</th> <th>telefono 2</th> <th >email</th> <th>fax</th> <th>note</th> <th>user</th> <th>password</th> <th>calendario</th> <th></th> </thead> <tbody> <tr ng-repeat="prezzo in prezzi"> <td>{{prezzo.id_utente}}</td> <td>{{prezzo.id_ruolo}}</td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.nome}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.nome" value="{{prezzo.nome}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.cognome}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.cognome" value="{{prezzo.cognome}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.comune}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.comune" value="{{prezzo.comune}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.indirizzo}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.indirizzo" value="{{prezzo.indirizzo}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.cap}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.cap" value="{{prezzo.cap}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.telefono1}}</div> <div ng-if="selectedprezzo == prezzo"><input type="tel" class="form-control" ng-model="prezzo.telefono1" value="{{prezzo.telefono1}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.telefono2}}</div> <div ng-if="selectedprezzo == prezzo"><input type="tel" class="form-control" ng-model="prezzo.telefono2" value="{{prezzo.telefono2}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.email}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.email" value="{{prezzo.email}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.fax}}</div> <div ng-if="selectedprezzo == prezzo"><input type="tel" class="form-control" ng-model="prezzo.fax" value="{{prezzo.fax}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.note}}</div> <div ng-if="selectedprezzo == prezzo"><input type="textbox" class="form-control" ng-model="prezzo.note" value="{{prezzo.note}}"></div> </td> <td>{{prezzo.user}}</td> <td>{{prezzo.password}}</td> <td>{{prezzo.calendario}}</td> <td> <div ng-if="selectedprezzo != prezzo"> <button ng-click="editprezzo(prezzo)" class="btn btn-primary">modifica</button> </div> <div ng-if="selectedprezzo == prezzo"> <button ng-click="salvaprezzo(prezzo)" class="btn btn-primary">salva</button> <button ng-click="resetprezzo()" class="btn btn-danger">annulla</button> </div> </td> </tr> </tbody> <tfoot> <tr> <td colspan="16" class="text-center"> <div st-pagination="" st-items-by-page="itemsbypage" st-displayed-pages="7"></div> </td> </tr> </tfoot> </table> </div>
in end see on site
<div ng-view="" class="ng-scope"> <div ng-controller="getprezzi" class="ng-scope"> </div><table st-table="prezzi" st-safe-src="prezzicollection" class="bootstrap-table table table-hover table-striped table-bordered tableblueth ng-scope"> <thead> <tr><th>id utente</th> <th>id ruolo</th> <th>nome</th> <th>cognome</th> <th>comune</th> <th>indirizzo</th> <th>cap</th> <th>telefono 1</th> <th>telefono 2</th> <th>email</th> <th>fax</th> <th>note</th> <th>user</th> <th>password</th> <th>calendario</th> <th></th> </tr></thead> <tbody> <!-- ngrepeat: prezzo in prezzi --> </tbody> <tfoot> <tr> <td colspan="16" class="text-center"> <div st-pagination="" st-items-by-page="itemsbypage" st-displayed-pages="7" class="ng-isolate-scope"><!-- ngif: numpages && pages.length >= 2 --></div> </td> </tr> </tfoot> </table> </div>
i add below page functioning of site have referred page
modificaprezzario.html
<div ng-controller="getprezzi" > <table st-table="prezzi" st-safe-src="prezzicollection" class="bootstrap-table table table-hover table-striped table-bordered tableblueth"> <colgroup> <col width="20%"> <col width="50%"> <col width="5%"> <col width="5%"> <col width="5%"> <col width="25%"> </colgroup> <thead> <tr> <th colspan="6"><input st-search="" class="form-control" placeholder="ricerca globale ..." type="text"/></th> </tr> <tr> <th colspan="6" style="padding-bottom: 2em;background:#fff"></th> </tr> <tr> <th st-sort="tariffa" class="pointer" title=tariffa">tariffa</th> <th st-sort="descrizione" class="pointer" title=descrizione">descrizione</th> <th st-sort="descrizione" class="pointer">unità di misura</th> <th st-sort="prezzo" class="pointer">prezzo listino</th> <th st-sort="prezzo_azie" class="pointer">prezzo aziendale</th> <th></th> </tr> </thead> <tbody> <tr ng-repeat="prezzo in prezzi"> <td>{{prezzo.tariffa}}</td> <td>{{prezzo.descrizione}}</td> <td>{{prezzo.unita_misura}}</td> <td>{{prezzo.prezzo}}</td> <td> <div ng-if="selectedprezzo != prezzo">{{prezzo.prezzo_azie}}</div> <div ng-if="selectedprezzo == prezzo"><input type="number" class="form-control" ng-model="prezzo.prezzo_azie" value="{{prezzo.prezzo_azie}}"></div> </td> <td> <div ng-if="selectedprezzo != prezzo"> <button ng-click="editprezzo(prezzo)" class="btn btn-primary">modifica</button> </div> <div ng-if="selectedprezzo == prezzo"> <button ng-click="salvaprezzo(prezzo)" class="btn btn-primary">salva</button> <button ng-click="resetprezzo()" class="btn btn-danger">annulla</button> </div> </td> </tr> </tbody> <tfoot> <tr> <td colspan="6" class="text-center"> <div st-pagination="" st-items-by-page="itemsbypage" st-displayed-pages="7"></div> </td> </tr> </tfoot> </table> </div>
controller.js
'use strict'; var myprezziario = angular.module('prezziario'); myprezziario.controller('prezziariocontroller', ['$scope', '$rootscope', '$location','$http', function ($scope, $rootscope, $location, $http) { $scope.selectedprezzo = ''; $scope.getprezzi = function() { $http.get('./api/prezzario/ricerca_prezzario.php'). success(function(data) { $scope.prezzi = data; $scope.prezzicollection= data; }); }; $scope.editprezzo = function(prezzo) { $scope.selectedprezzo = prezzo; }; $scope.salvaprezzo = function(prezzo) { $http.post('./api/prezzario/aggiorna_prezzo.php', { 'id_prezzario' : prezzo.id_prezzario, 'prezzo_azie' : prezzo.prezzo_azie } ).success(function (data, status, headers, config) { $scope.resetprezzo(); }); }; $scope.resetprezzo = function() { $scope.getprezzi(); $scope.selectedprezzo = ''; }; $scope.go = function ( path ) { $location.path( path ); }; }]);
ricerca_prezzario.php
<?php require_once '../includes/dbconnector.php'; // query records users table $sql = 'select a.id_prezzario, a.tariffa, a.descrizione, a.unita_misura, a.prezzo, a.prezzo_azie sal_d_prezziario order a.tariffa'; // use prepared statements, if not strictly required practice $stmt = $conn->prepare( $sql ); // execute query $stmt->execute(); // fetch results array $result = $stmt->fetchall( pdo::fetch_assoc ); // convert json $json = json_encode( $result ); // echo json string echo $json; ?>
aggiorna_prezzo.php
<?php require_once '../includes/dbconnector.php'; $sql = "update sal_d_prezziario set prezzo_azie = :prezzo_azie id_prezzario = :id"; $stmt = $conn->prepare($sql); $stmt->bindparam(':prezzo_azie', $data->prezzo_azie); $stmt->bindparam(':id', $data->id_prezzario); $stmt->execute(); ?>
Comments
Post a Comment