让我先说一下我是一个初学者和整体菜鸟,使用Angular和JSON调用。
我正在对JSON对象(?)进行$ http.get调用,它看起来像这样:
[{
path: "site:images/gallery/1238.jpg",
data: {
caption: "",
url: ""
}
}, {
path: "site:images/gallery/abelone.jpg",
data: {
caption: "",
url: ""
}
}, {
path: "site:images/gallery/carrot.jpg",
data: {
caption: "",
url: ""
}
}, {
path: "site:images/gallery/cream.jpg",
data: {
caption: "",
url: ""
}
}, {
path: "site:images/gallery/img_2679.jpg",
data: {
caption: "",
url: ""
}
}, {
path: "site:images/gallery/img_4908.jpg",
data: {
caption: "",
url: ""
}
}]
我这样称呼它:
$http.get('/_admin/index.php/rest/api/galleries/get/Restaurant?token=xxx')
.then(function(response) {
$scope.gallery = response.data;
});
并使用ng-repeat:
<article ng-repeat="item in gallery">
<p>{{item.path}}</p>
</article>
我需要的是以某种方式从每个site:
“记录”中删除path
关键字。
答案 0 :(得分:0)
response.data.path与字符串中的“site:”前缀一起返回,与$ http调用无关,所以它只是简单的字符串操作。试试这个:
<article ng-repeat="item in gallery">
<p>{{ item.path.slice(5) }}</p>
</article>