, 나는 데이터의 매트릭스 (테이블)을로드 할 페이지를 필요, 그래서 모든 데이터를 얻기 위해 3 개 요청합니다Anagular에서 페이지를 렌더링하려면 모든 데이터로드 ajax를 완료하는 방법? 내 페이지에서
- 열 데이터를
- 행 데이터
- 관계 데이터
모든 데이터가있는 후 관계 데이터를 가져 오는 데 getRelation(columnIndex, rowIndex)
함수를 사용합니다.
하지만 열이 앞에로드 될 때 Angular는 내 getRelation
메서드를 렌더링하려고 시도하지만 열 데이터가 없기 때문에 오류가 발생합니다.
아마도 내 기능에 if
조건을 넣을 수는 있지만 그저이 상황을 해결하는 데 더 좋은 방법이 있습니까?
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;
}.bind(this);
$http.post(url, {}).then(function(res) {
this.rows = res.data;
}.bind(this));
// same code for columns and relations
사용 NG 쇼 또는 NG-경우 –
당신은, 당신이 – Merlin
@Lorenzo 내가 내 게시물을 업데이트하여 요청을하기 위해 사용하는 코드를 보여줄 수 요청 예를 가하고 – Lai32290