Error: Controller 'uiGrid', required by directive 'uiGridRow'?
Hello, I found an error when grid in bootstrap modal. As the grid in modal show the first time, everything is fine, but the second time rendering always print the error log: Error: [$compile:ctreq] Controller 'uiGrid', required by directive 'uiGridRow', can't be found! ... in console. Could you give me some hint or suggestions?

Could you provide a plunker perhaps of this? The tutorial: http://ui-grid.info/docs/#/tutorial/110_grid_in_modal does not have this behaviour, so it would be some interaction with your code, but we'd need an example to diagnose.
Thanks for response. Let me ask one question first, the modal html including grid should be $compile every time? May I put it in a script template, partial code like below.
<script type="text/ng-template" id="assistorModal">
<div class="modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-body">
<form class="form-horizontal container-fluid" role="form">
<div class="row">
<button type="button" class="close" ng-click="$hide()">×</button>
<button type="button" class="btn btn-primary" ng-click="assistor.setSymbol()">區間符號</button>
</div>
</form>
<div style="height:4px;"></div>
<div ui-grid="assistor.gridOpts" class="grid" ui-grid-selection ui-grid-resize-columns ui-grid-auto-resize></div>
</div>
</div>
</div>
</div>
</script>
show grid modal js
$scope.assistor.modal = $modal({
template: 'assistorModal',
show: false,
backdrop: 'static',
scope: $scope
});
$http.post(...).success(function (data) {
// prepare the columnDefs and data dynamically ...
$scope.assistor.gridOpts.columnDefs = cols;
$scope.assistor.gridOpts.data = data.rsList;
$scope.assistor.modal.$promise.then(function () {
$scope.assistor.modal.show();
});
});
...
I don't see any reason you couldn't, so long as you're not trying to manipulate the grid before the modal has shown. You'd also have to be careful that your various variables weren't holding a reference to the old grid when a new one is rendered - so look out for things like gridApi which might be pointing to the old grid (and therefore causing that grid not to be garbage collected, as well as giving errors if you called methods within it).
In my application I do something similar, but I put all the grid setup on the modal controller itself. That way when the modal goes away, so does the grid, and when I start a new modal, it definitely has a new grid and new variables.
OK, I try to figure out of it. Thanks a lot.
Assuming original question resolved, as no new comments for 3 weeks. Closing.
I'm getting the same error with a modal. Only happens the second time I open the window. I'm adding rows to the grid through a $scope.$on event. Not sure what the difference would be. I'm guessing some kind of issue with it cloning or copying the grid object. The grid itself works fine, just throws the nasty error. If I put together a plunkr or jsfiddle how high would the priority be on this?
Right now I get around it by passing in an object that contains the grid.data. It works for one grid. Problem is, I need to update a grid on another controller. My broadcast has no knowledge of the other grid (which is a good design IMHO). Tying the data this way is also coupling the grid and other controller together which sucks.
I'd even go with a way to just suppress the error. I might look into this next as there seems to be nothing "bad" happening to the grid to affect its usability or function. Everything's working fine.
function addFacility(newFacility) {
var broadcast = { facilityId: newFacility.facilityId, areaSize: newFacility.usingSize, tenantId: data.tenantId, tenantName: data.tenantName, data: tf.facilityTenants.data };
tf.newAreaSize = 1;
tf.newDescription = '';
common.$broadcast('newFacility', broadcast);
}
$scope.$on('newFacility', (event, newFacility) => {
if ('data' in tf.facilityTenants) {
newFacility.data.unshift(newFacility);
} else {
newFacility.data = [newFacility];
}
_.remove(tf.availableFacilityTenants, (facility: fResponse.IFacility) => {
return facility.facilityId == newFacility.facilityId;
});
})
I am getting the same 'Error: [$compile:ctreq] Controller 'uiGrid', required by directive 'uiGridHeaderCell', can't be found!' error described above when trying to implement a custom filter modal. The same error is reproducable in the custom filter tutorial (http://ui-grid.info/docs/#/tutorial/306_custom_filters). These errors don't seem to cause any functionality problems but it would be great to have a way to get rid of them.
Produced by my custom filter modal:

Prouded by the custom filter modal in the Grid UI tutorial (click on the '...' on the Age header). The error will display on the second time.

Have the same issue with $mdDialog of Angular material
i am having this problem as well, i believe it's a conflict with something else
I also have this issue.
I also can see this issue under custom filters. If you click the age column button again after filtering.
Hi guys, I solved the error with.. <div data-ng-if="!refresh" data-ui-grid="whatever.gridOptions"></div>
the bit of ng-if refresh was what I needed. it's a part of angular.
please open another ticket for this error, I got the same issue.
I got the same issue too.
Guys - when you have an error, try to reproduce them on plnkr. If you can't, it is probably something with your code. If you can, someone could actually look into them. Can anyone reproduce this on plnkr?
The issue shows up when use ui-grid with modal(I use angular strap, http://mgcrea.github.io/angular-strap/) . When the modal is dismissed the HTML DOM of the modal is removed but angular scope of the modal is not destroyed and left over. At this moment the error will start to happen.
If I open and close the modal repeatedly I can see this error more and more times.
I destroy the scope manually before the modal is hidden then the error will not show any more.
Is there any solution for this issue, Or any alternative method ?
I am getting the same error "Controller 'uiGrid', required by directive 'uiGridRow', can't be found!" http://plnkr.co/edit/Kq09kuEF2vFJyjwQ5uxC Just click "Show modal" 2 times.
getting the same error - but with no modal. I just did a gulp rebuild on my app and it started happening
Seeing the same thing on our app...no modal.
We are showing multiple "grids" in tabs. When the user rapidly switches between tabs, sometimes this error gets thrown. Will troubleshoot more but according to boilerplate angular error documentation, uiGrid controller is not yet created when uiGridRow is being rendered. Perhaps its in the destroy, that before leaving a tab, a uiGridRow is trying to render or access its uiGrid controller, but the uiGrid controller has already been disposed?