AngularJS的解析错误



我在控制台上遇到以下错误

"Error: [$parse:syntax] http://errors.angularjs.org/1.4.12/$parse/syntax?p0=Detail&p1=is%20an%20unexpected%20token&p2=11&p3=carrental%09Detail.hostDescription&p4=Detail.hostDescription

这意味着

Error: $parse:syntax
Syntax Error
Syntax Error: Token 'Detail' is an unexpected token at column 11 of the expression [carrentalDetail.hostDescription] starting at [Detail.hostDescription].

但是在我的php中检索mysql数据库的数据

$carrentalhost = $this->master_model->getRecords('carrentalhost', ['carrentalId' => $carrentalId])[0];
if(!empty($carrentalhost['hostImage'])){
$hostImage= base_url() . 'resources/carrentals/carrentalhost/' . $carrentalhost['hostImage'];
}  else {
$hostImage=null;
}
$categoryId = $this->master_model->getRecords('module_category', ['module_id' => 8], 'id')[0];
$mobileNumber = $carrentalhost['hostMobile'];
$resultArray = [       
'hostName' => $carrentalhost['hostName'],
'hostEmail' => $carrentalhost['hostEmail'],
'hostDescription' => $carrentalhost['hostDescription'],
'price' => $carrentalhost['price'],
'selectedDates' => $carrentalhost['availableDates']
];        
if (!empty($resultArray)) {
$responseArray = array(
'result' => $resultArray,
'success' => true);
return $this->set_response($responseArray, REST_Controller::HTTP_OK);
} 

我检查了我的PHP代码,我可以从数据库中检索正确的数据。

在我的 AngularJS 方面,

var loadCarrentalDetails = function () {
var query = {};
var loadCarrentalDetailsReq = CarrentalResource.loadCarrentalDetails(query);
loadCarrentalDetailsReq.success(function (loadCarrentalDetailsRes) {
$scope.carrentalDetail = loadCarrentalDetailsRes.result;                
});
loadCarrentalDetailsReq.error(function () {
});
}
loadCarrentalDetails();

可能出了什么问题?

检查您的响应,因为响应可能不是有效的 JSON 对象。

有效的 JSON

[
{"field":"value1"},
{"start-time":"2017-07-12T00:34:36.000Z"}
]

无效的 JSON

[
{"field":"value1"},
{start-time:2017-07-12T00:34:36.000Z}
]

相关内容

  • 没有找到相关文章

最新更新