There is such an array:
$scope.ChemicalGroups [ ... HashName: "G815D9D3776614A985A4B18E437349DE2" ... ] There is such code:
$scope.ChemicalGroups.forEach(function (chemicalGroup) { var valStrl = chemicalGroup.HashName; chemicalGroup[valStrl] = { enableColumnMenus: false, enableHorizontalScrollbar: 2, enableVerticalScrollbar: 2, data: [] }; }); Ie, I can have as many elements as possible in the ChemicalGroups array and for each I need to create a ui-grid. I want to use the HashName field as the grid's unique name (gridOptions).
Html code:
<div id="{{item.Id}}" class="panel-collapse collapse in"> <div class="panel-body"> <div ui-grid="item[HashName]" class="grid"> </div> </div> </div> In this case, an exception is generated, writes: Token '[' is not a valid
It also does not work this way - ui-grid={{item[HashName]}}
I tried to do this:
$scope.ChemicalGroups.forEach(function (chemicalGroup) { var valStrl = chemicalGroup.HashName; var model = $parse(valStrl); model.assign($scope, { enableColumnMenus: false, enableHorizontalScrollbar: 2, enableVerticalScrollbar: 2, data: [] }); }); Html:
<div id="{{item.Id}}" class="panel-collapse collapse in"> <div class="panel-body"> <div ui-grid="item.HashName" class="grid"></div> </div> </div> In this case, in the standard ui-grid.js script , an exception occurs because the string HashName is passed there. Although in $ scope I added an object before it, which is also named as a HashName line - model.assign($scope... (I checked it in $ scope). But this expression: ui-grid = "item.HashName" For some reason, it does not receive an object but a string.
How to make it recognize exactly the object with that name? Is it possible to transfer any javascript expression in ui-grid="" , for example: {{item[HashName]}} , as far as I understand it is impossible to do so. Any suggestions.
ui-grid="item.[HashName]"- here and in the usual javascript there will be a syntax error. - Grundy