Angular UI display error: $ uibModal - undefined

I am trying to run AngularUI Modal, but it gives me an error ($ uibModal - undefined) as well as a headache.

I am using angular -ui-bootstrap-0.14.3 version. (so it uses $ uibModal, not $ modal)

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

This is a shortened version of my controller (which contains a 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 host 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 would be greatly appreciated. itsdanny.

+4
source share
1 answer

Doh, I have not introduced a dependency for $ uibModal, $ log.

+1
source

Source: https://habr.com/ru/post/1614639/


All Articles