Lai32290 Lai32290 - 3 months ago 16
Ajax Question

How to wait all data load ajax complete to render page in Anagular?

In my page, I need a page to load a matrix of data (a table), so I make 3 requests to get all data:

  • Columns data

  • Rows data

  • Relationship data

After has all datas, I using a function
getRelation(columnIndex, rowIndex)
to get relation data.

But when rows are loaded before then columns, Angular will try to execute my
method to render, but it will occur an error because has not column data.

Maybe I can just put an
condition in my function, but I just want know, has some way better to resolve this situation?

this.relations = [];
this.columns = [];
this.rows = [];
this.getRalation = function getRalation(columnIndex, rowIndex) {
var column= this.columns[columnIndex];
var row= this.rows[rowIndex]

var relation = $myService.getSomthing(this.relations, column.ID, row.ID);

return relation;

$, {}).then(function(res) {
this.rows =;

// same code for columns and relations


use $q service:

$q.all([/*promise from row request*/,/*promise from column request*/]).then(function(result){
     var rows = result[0];
     var columns = result[1];
     //parse row and cols, use getRalation here