Angularjs在更新后重新加载xml数据 [英] Angularjs reload xml data after updating
问题描述
我正在使用angularjs + php。在我的函数中,我使用代码:
$ scope.addComment = function()
{
var request = $ http({
方法:post,
url:xmlAction.php,
数据:{
id:shopItemID ,
functionname:'addNewComment',
描述:'描述评论',
名称:'Alex'
},
标题:{'Content-Type':'application / x-www-form-urlencoded'}
});
loadComment();
};
函数loadComment(){
services.getComments()。然后(函数(数据){
var source = x2js.xml_str2json(data.data);
var comments =($ filter('filter')(source.data。评论,{itemID:shopItemID}));
$ scope.comments =评论;
});
};
我调用函数addComment后,它仍然在缓存中加载xml数据。如何清除缓存中的xml数据并重新加载?
谢谢。
Hi ,
I am using angularjs + php. In my function i use the code:
$scope.addComment = function()
{
var request = $http({
method: "post",
url: "xmlAction.php",
data: {
id:shopItemID,
functionname: 'addNewComment',
description: 'Description Comment',
name:'Alex'
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
loadComment();
};
function loadComment(){
services.getComments().then(function(data){
var source = x2js.xml_str2json(data.data);
var comments = ($filter('filter')(source.data.comment, {itemID: shopItemID }));
$scope.comments = comments;
});
};
After i call function addComment, it still loads xml data in cache. How can i clear xml data in cache and reload it again ?
Thanks.
推荐答案
范围。 addComment = function()
{
var request =
scope.addComment = function()
{
var request =
http({
method:发布,
url:xmlAction.php,
数据:{
id:shopItemID,
functionname:'addNewComment',
描述:'描述评论',
名称:'Alex'
},
header:{'Content-Type':'application / x-www-form-urlencoded'}
});
loadComment();
};
函数loadComment(){
services.getComments()。然后(函数(数据){
var source = x2js.xml_str2json(data.data);
var comments =(
http({
method: "post",
url: "xmlAction.php",
data: {
id:shopItemID,
functionname: 'addNewComment',
description: 'Description Comment',
name:'Alex'
},
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
});
loadComment();
};
function loadComment(){
services.getComments().then(function(data){
var source = x2js.xml_str2json(data.data);
var comments = (
filter ('过滤器')(source.data.comment,{itemID:shopItemID}));
filter('filter')(source.data.comment, {itemID: shopItemID }));
这篇关于Angularjs在更新后重新加载xml数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!