0
我不會講英語非常好,所以我提前道歉爲我的拼寫錯誤角JS - NG-重複錯誤
我創建的網站上用戶管理頁面已經有角的js開發的,但它是第一個我使用它的時間,我無法找出錯誤
當我點擊index.html頁面上的列表返回到頁面amministrazione2.html,其中「應該」啓動腳本以獲取數據從數據庫並插入表中,但視頻顯示
<tbody> <!-- ngRepeat: prezzo in prezzi --> <t/ body>
,而不是我的數據
這是index.html的,那裏是在左邊,埃夫裏項目的列表重定向到的.html頁面
<!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>
這是那裏有該元素的頭在左邊的列表上
<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>
這是其中存在角模塊的declaretions文件app.js
'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' });
}])
這是我的PHP文件上搜索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 FROM `sal_t_utente` a ORDER BY a.id_utente";
// use prepared statements, even if not strictly required is good practice
$stmt = $conn->prepare($sql);
// execute the query
$stmt->execute();
// fetch the results into an array
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
$json = json_encode($result);
return $json;
}
?>
的用戶信息,這是角控制器我已經創造插入和修改表
'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);
};
}]);
的數據是這樣的amministrazioni2.html,顯示在此最終用戶信息
<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>
是我在網站上看到
<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>
首先認爲我注意到的是你沒有任何getPrezzi控制器,但AmmiController – Marko