当我使用$ http.post调用web服务时,我正在使用AngularJS并面临$ interpolate:interr错误。
这是我的来源:
myportletServices.factory('Usage', ['$http', '$sce', 'Settings', 'Alert', function($http, $sce, Settings, Alert){
this.query = function(callback){
var url = $sce.getTrustedResourceUrl(Settings.webServiceUrl + '/usage?userid=' + Settings.screenName);
var http = $http.post(url); //--> Error occurs
http.success(function(data, status, headers, config) {
if (data.ok==true) {
if (callback)
callback(data.result)
} else {
Alert.add('Alert', data.message);
}
});
http.error(function(data, status, headers, config) {
Alert.add('Error', data);
});
};
return this;
}]);
从服务器返回:
{
"ok": true,
"message": "",
"result":
[
{
"phoneid": xxxxxx,
"phonenumber": xxxxxxxx,
"planid": xx,
"planname": "$29 Plan",
"cap":
[
{
"stdcap": 165,
"datacap": 100,
"smscap": 0
}
],
"usage":
[
{
"stdusage": 97.99,
"datausage": 56.044,
"smsusage": 0
}
]
},
{
"phoneid": xxxxx,
"phonenumber": xxxxx,
"planid": xx,
"planname": "Essentials $45 Plan",
"cap":
[
{
"stdcap": 650,
"datacap": 1000,
"smscap": 6000
}
],
"usage":
[
{
"stdusage": 116.51,
"datausage": 253.339,
"smsusage": 63
}
]
},
{
"phoneid": xxxxx,
"phonenumber": xxxxxxx,
"planid": 80,
"planname": "Medium $25 Pack",
"cap":
[
{
"stdcap": 500,
"datacap": 1500,
"smscap": 6000
}
],
"usage":
[
{
"stdusage": 90.05,
"datausage": 115.237,
"smsusage": 108
}
]
}
]
}
错误讯息:
Error: [$interpolate:interr] http://errors.angularjs.org/1.3.0-beta.2/$interpolate/interr?p0=%7B%7Busage…usage.planname%7D%7D&p1=TypeError%3A%20undefined%20is%20not%20a%20function
at Error (native)
我找到的错误与使用错误的表达式格式有关但我的情况发生在我从webservice获得结果时。是否会发生因为返回数据有特殊字符,如美元符号?
请解释错误并提供一些帮助以解决问题。 谢谢,您的帮助将不胜感激。