我在執行PUT請求後無法更新我的ng-repeat列表。服務工作正常。如何在http請求後更新ng-repeat列表
controller.js
teamData.updateTeam(team.id, teamObj, function(res) {
console.log('Success');
});
service.js
teamService.updateTeam = function(teamId, param, callback) {
var req = {
method: 'PUT',
url: '/team' + teamId,
headers: {
'Content-Type': 'application/json'
},
'data': param
};
return $http(req).then(function(res){
callback(res);
}, function(err){
callback(err);
});
};
teamRoute.js
app.put('/team/:id', function(request, response) {
var options = {
host: reqParam.hostFramework,
path: reqParam.path + '/team/' + request.params.id,
method: 'PUT',
headers: {
'token': reqParam.token,
'Content-Type': 'application/json',
'Content-Length': Buffer.byteLength(JSON.stringify(request.body))
}
};
var resString = '';
var req = https.request(options, function(res) {
res.setEncoding('utf8');
res.on('data', function(d) {
resString += d;
});
res.on('end', function() {
response.send(resString);
});
});
req.write(JSON.stringify(request.body));
req.end();
});
team.html
<div ng-repeat="team in teamData">
<h2>{{team.name}}</h2>
....
</div>
我的目標是在發出PUT請求(不刷新頁面)後立即更新ng-repeat列表。我怎樣才能實現它?
你應該只能夠推任何你想進入你的請求過程中重複什麼之前/後/。 –
'ngRepeat'部分在哪裏?如何在請求後更新項目?我們應該猜測? –
添加teamRoute.js和team.html文件 – Laurynas