[英]Retrieve specific row from database and display all the data in the specific row and send json using php
[英]i can't retrieve all data of a specific row with angular
我正在用angular和php构建一个项目。 我有一个客户表,我可以检索所有表数据,当我输入一个特定的客户时,它只显示customer_id,而不显示其余的客户详细信息。 有人可以帮忙吗?
customerCardDetailsCtrl.js-该页面的控制器,用于显示特定客户的所有信息:
"use strict";
angular.module('dataSystem').controller('customerCardDetailsCtrl', function($scope, $http ,$routeParams, $location) {
var customer_id = $routeParams.customer_id;
$scope.customer_id = customer_id;
$http.get('http://localhost:8081/hamatkin/api/get-allCustomers.php/'+ customer_id).success(function(data){
$scope.customerDetail = data;
});
});
customerCardDetails.html-仅显示customer_id
html页面
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
</head>
<body>
<div class="customer">
<h1>כרטיס לקוח</h1>
<a href="/hamatkin/index.html#/customerCards">חזור לרשימת כרטיסי הלקוחות</a>
<h1 ng-bind="customerDetail.customer_id"></h1>
</div>
</body>
</html>
app.js-
.when('/customerCardDetails/:customer_id', {
controller: "customerCardDetailsCtrl",
templateUrl: '../hamatkin/Views/customerCardDetails.html',
screenTitle: "",
costumerHidden: false,
reportsHidden: true,
stockHidden: true,
isIncome_expensesHidden: true,
isNavTabHidden: false,
isFooterHidden: false,
ordersHidden: true
设计错误。
在控制器中-您正在使用路由参数,尽管它们不在路由URL上。 您的api在customerDetail中返回数据,理想情况下,此对象应该具有您要寻找的客户的详细信息。 因此在html绑定中使用它。
在html中-最外面的div使用ng-model,这是错误的,因为它的2种方式绑定使用ng-bind。
Ng-model具有未定义的范围对象。
代码中还有更多的pblms。 复习一下
不知道您在用ng-models="customers"
做什么,因为该变量未在任何地方定义-您可以删除该位。
整个块从var kind_Of_Customer
开始,以$scope.activePath = null;
结尾$scope.activePath = null;
可以删除。
您需要从GET请求返回的数据,因此请在GET请求的回调中进行处理。 或者你可以替换
<h1>{{customer_id}}</h1>
与
<h1>{{customerDetail.customer_id}}</h1>
。
<h1 ng-bind="customerDetail.customer_id"></h1>
(我也建议将这样的请求放在服务中以将两者分开)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.