Legion Legion - 1 year ago 98
Javascript Question

Why am I getting an angular unknown provider injector error when passing an array to a modal?

I keep getting this error when trying to open a modal that takes an array as a parameter: https://docs.angularjs.org/error/$injector/unpr?p0=listItemsProvider%20%3C-%20listItems%20%3C-%20SingleActionListModalCtrl

Here's the controller:

controller('SingleActionListModalCtrl', ['$scope', '$uibModalInstance', 'modalTitle', 'modalText', 'listItems', 'cancelBtnCaption', 'cancelBtnFunction',
function ($scope, $uibModalInstance, modalTitle, modalText, listItems, cancelBtnCaption, cancelBtnFunction) {

$scope.modalTitle = modalTitle;
$scope.modalText = modalText;
$scope.list = listItems;
$scope.cancelBtnCaption = cancelBtnCaption;

$scope.cancel = function () {

Here's the view for the modal:

<script type="text/ng-template" id="EventFooterSingleActionListModal">
<div class="modal-header">
<h3 class="modal-title">{{ modalTitle }}</h3>
<div class="modal-body">
{{ modalText }}
<li ng-repeat="listItem in list track by $index">{{ listItem }}</li>
<div class="modal-footer">
<button class="btn btn-primary" type="button" ng-click="cancel()">{{ cancelBtnCaption }}</button>

Here's the function definition:

ModalFactory.OpenSingleActionListModal = function (modalName, title, msg, listItems, cancelCaption, cancelFunction) {
var modalInstance = $uibModal.open({
animation: true,
templateUrl: modalName,
controller: 'SingleActionListModalCtrl',
size: null,
resolve: {
modalTitle: function () {
return title;
modalText: function () {
return msg;
list: function() {
return listItems;
cancelBtnCaption: function () {
return cancelCaption;
cancelBtnFunction: function () {
return cancelFunction;

And here's the function call:

'Modal title', 'Modal text',
['list item 1', 'list item 2'],
'Close', function () { });

Answer Source

In your controller, you named it listItems, in your resolve it's list

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download