我正在用angular和php构建一个项目。我正试图从客户表中获取一个特定的“客户”,并在页面上显示他的详细信息,但它不起作用。我从控制台得到的错误 - angular.js:13550错误:[$ parse:lexerr] http://errors.angularjs.org/1.5.5/ $ parse / lexerr?p0 =意外%20nextharacter%20& p1 = s%200-0%20%5B%23 %5D&安培; P2 =%23%2FcustomerCardDetails%2FcustomerDetails.customer_id
这是我的代码:
Customer.php
<?php
class Customer {
private $table_name = "customers";
public $customer_id;
public $kind_Of_Customer;
public $full_name;
public $id;
public $city;
public $address;
public $phone;
public $phone_2;
public $email;
public $fax;
public $referrer;
public $comments;
}
?>
readCustomer.php
<?php header('Content-Type: text/html; charset=utf-8');
include_once 'Customer.php';
$con = mysqli_connect('localhost','root','','hamatkin');
mysqli_query($con,"SET character_set_client = utf8");
mysqli_query($con,"SET character_set_connection = utf8");
mysqli_query($con,"SET character_set_results = utf8");
$customer = new Customer();
$query = "SELECT customer_id, kind_Of_Customer, full_name, id, city, address,phone,phone_2 FROM customers where customer_id= 82";
$result = $con->query($query);
$row = mysql_fetch_assoc($result);
// reset the result resource
mysql_data_seek($result, 0);
if( $result->num_rows==1)
{
$customer->kind_Of_Customer = $row['kind_Of_Customer'];
$customer->full_name =$row['full_name'];
$customer->id = $row['id'];
$customer->city = $row['city'];
$customer->address = $row['address'];
$customer->phone = $row['phone'];
$customer->phone_2 = $row['phone_2'];
}
$res = json_encode($customer);
echo json_encode($res);
?>
customerCardDetailsCtrl.js - controller
"use strict";
angular.module('dataSystem').
controller('customerCardDetailsCtrl', function($scope, $http ,$routeParams, $location) {
var customer_id = $routeParams.customer_id;
$scope.customer_id = customer_id;
var data = $.param({
customer_id: customer_id
});
var config = {
headers : {
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8;'
}
}
$http.post('api/readCustomer.php',data,config ).
success(function(data){
$scope.customerDetails = data;
console.log($scope.customerDetails);
}).
error (function (error) {
colsole.log(error);
});
});
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