I ran into an issue the other day on our test environment at work. It was a bug that I couldn't reproduce locally, and it drove me crazy. Here is the link that angular was giving when the error occurred:
Here is the code in question:
$modal.open({
template: '<agent-chart widgets="modalCtrl.widgets" chart-title="modalCtrl.chartName"></agent-chart>',
// ...
resolve: {
widgets: function() {
return $scope.widgets;
},
chartName: function() {
return chartName;
},
}
// ...
})
Again, it works fine locally, yet angular is telling me that the $injector could not resolve dependencies. The dependencies it is referring to are the widgets and chartName, which are both set up in the resolve object, and passed into the controller function.
The Simple Fix
The solution: change the controller declaration to be an array, passing in the items to be injected, and having the last item be the function declaration:
controller: ['widgets', 'chartName', function(widgets, chartName) {
this.widgets = widgets;
this.chartName = chartName;
}],
// ...
Yep, just like that. It appears that this is only an issue in minified code, and works fine otherwise. It's a silly bug, but easy to fix once you know what the issue actually is. Happy bug hunting, friends!
