简体   繁体   中英

Angular UI pop up error: $uibModal is undefined

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.

Doh,我没有为$ uibModal,$ log注入依赖项。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM