这里我的API代码应该向我的前端发送一个简单的字符串:
//server.js
app.get('/api/headline', function(req, res) {
res.json(headline.headline);
console.log(headline);
});
//headline.json
{
"headline" : "here is the new headline"
}
我的输出是:
“这是新标题”
但我希望没有引号的回复“”
编辑添加Angular-Code:
angular service:
return {
get : function() {
return $http.get('/api/headline');
}
}
angular controller:
headlineService.get()
.success(function(data) {
vm.headline = data;
});
angular directive:
function headliner() {
return {
restrict: 'EA',
replace: true,
template: '<div><strong>ATTENTION</strong> {{main.headline}}</div>'
};
}
感谢您的帮助!