vendredi 9 janvier 2015

Angularjs $http my second then before first then is done.


Vote count:

0




I am not sure what I am doing wrong here, but the Report.xls gets downloaded before report.students gets updated. How can I make it wait for report.students to be updated before Report.xls get downloaded?


Here is my code


`data service function



function getStudentsForExcel() {

var filter = studentFilter;

filter.data.perPage = StudentsModel.data.countTotal;
return $http.post(url + "/summeries", filter.data)
.then(onStudentSummeries)
.catch(onError);

function onStudentSummeries(response) {

return response.data;

}
}`


This function in my controller `



function tocsv() {
studentData.getStudentsForExcel().then(function(data) {
report.students = data;





}).then(function() {
var blob = new Blob([document.getElementById('tableReport').innerHTML], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
saveAs(blob, "Report.xls");
});



}`


asked 33 secs ago







Angularjs $http my second then before first then is done.

Aucun commentaire:

Enregistrer un commentaire