4
votes

I'm trying to get an AngularUI Modal going but it's giving me an error ( $uibModal is undefined) as well as a headache.

I'm using version angular-ui-bootstrap-0.14.3. (so it uses $uibModal and not $modal)

The error shows against the line var modalInstance = $uibModal.open({...

This is a cut down version of my controller (which holds the click event)

'use strict';
    angular.module('MPAapp')
        .controller('workCentreCtrl',
                    ['$scope', '$rootScope', 'toastrFactory', 'workCentreResource',
                     workCentreCtrl])

  function   workCentreCtrl($scope, $rootScope, toastrFactory, workCentreResource, $uibModal, $log) {
        // Click event code to open the modal
        $scope.EditWorkOrder = function (slot, max) {            
            var modalInstance = $uibModal.open({
                animation: true,
                templateUrl: '/app/WorkOrder/Views/EditWorkOrder.html',
                controller: 'EditWorkOrderCtrl',
                size: 'lg',
                resolve: {
                    Slot: function () {
                        return slot;
                    },
                    Max: function () {
                        return max;
                    }
                }
            });

            modalInstance.result.then(function (selectedItem) {
                $scope.selected = selectedItem;
            }, function () {
                $log.info('Modal dismissed at: ' + new Date());
            });
            console.log('md opened')
        };
    }

This is the receiving controller

    'use strict';
    angular.module('MPAapp')
        .controller('EditWorkOrderCtrl', ['$scope', '$timeout', 'toastrFactory', 'workCentreResource', 'blockedDatesResource',
            EditWorkOrderCtrl]);

    function EditWorkOrderCtrl($scope, $timeout, toastrFactory, workCentreResource, blockedDatesResource, $uibModalInstance, Slot, Max) {
// rest of my code in here....
};

Any ideas on this will be very much appreciated. itsdanny.

1
I not understand your code. What is workCentreCtrl?Emir Marques
The word function is missing, I've updated the OP.ItsDanny

1 Answers

1
votes

Doh, I hadn't injected the dependency for $uibModal, $log.