在javascript for for循环

时间:2015-10-05 12:40:03

标签: javascript html angularjs

我正在for循环中构建一个HTML模板,我想将变量值传递给模板,并构建动态模板。

下面是我的for循环,我需要在HTML的Span标记中传递colIndex值,这里提到“需要colIndex here”

for (var colIndex = 0; colIndex < colCount; colIndex++) {
  $scope.gridOptions.columnDefs.push({
    name: 'col-' + colIndex,
    aggregationType: uiGridConstants.aggregationTypes.sum,
    width: 85,
    treeAggregationType: uiGridTreeViewConstants.aggregation.SUM,
    cellTemplate: '<div class="ui-grid-cell-contents">'+
                  '<span ng-if="!(row.entity[\'$$\' + col.uid])">{{row.entity[\'col-'+'<<Need colIndex here>>'+'\'] CUSTOM_FILTERS}}</span>'+
                  '<span ng-if="row.entity[\'$$\' + col.uid]"> {{row.entity["$$" + col.uid].value CUSTOM_FILTERS}}</span>'+
                  '</div>'
  });
}

请建议。

1 个答案:

答案 0 :(得分:0)

你可以这样做,

8.8.8.8