角1.7.8-错误:$ injector:unpr未知提供者

时间:2019-07-09 04:20:09

标签: angularjs fullcalendar

我坚持这个问题大约一个小时,我想做的是使用resolve参数将数据范围列表传递给模式的控制器,但它在显示以下内容时引发错误:

Unknown provider: NewEventProvider <- NewEvent <- modalCalendar

NewEvent不能是要插入我的应用程序模块中的服务,而只能是数据列表。

这是我的日历控制器:

app.controller('calendar.controller', function($scope, $compile, 
$uibModal, uiCalendarConfig) {

$scope.newEvents = {}

$scope.uiConfig = {
    calendar: {
        height: 350,
        displayEventTime: true,
        timeFormat: 'hh:mm',
        editable: false,
        selectable: true,
        selectHelper: true,
        lazyFetching: true,
        fixedWeekCount: false,
        lang: 'ru',
        timeZone: 'local',
        header: {
            left: 'month agendaWeek agendaDay',
            center: 'title',
            right: 'today prev,next'
        },
        select: function(start, end) {
            var fromDate = moment(start).format('YYYY-MM-DD hh:mm:ss')
            var endDate = moment(end).format('YYYY-MM-DD hh:mm:ss')
            $scope.newEvents = {
                EventId: 0,
                StartAt: fromDate,
                EndAt: endDate,
                IsFullDay: false,
                Title: '',
                Description: ''
            }
            $scope.ShowModal()
        }
    },
}

$scope.ShowModal = function() {
    $scope.option = {
        templateUrl: '/static/snippets/modalCalendar.html',
        controller: 'modalCalendar',
        // controllerAs: ,
        reslove: {
            NewEvent: function() { return $scope.newEvents }
        }
    }

    var modal = $uibModal.open($scope.option)

    modal.result.then(function(data) {
        $scope.newEvents = data.event
        switch (data.operation) {
            case 'Save':
                break
            case 'Delete':
                break
            default:
                break
        }
    }, function() {
        console.log('Modal dialog closed!')
    })
}

});

模态控制器:

app.controller('modalCalendar', ['$scope', '$uibModalInstance', 'NewEvent', function($scope, $uibModalInstance, NewEvent){

    $scope.newEvents = NewEvent

    $scope.error_message = ""

    $scope.ok = function(){
        console.log('Save')
    }

    $scope.delete = function(){
        console.log('Delete')
    }

    $scope.cancel = function(){
        console.log('cancel')
    }

}])

1 个答案:

答案 0 :(得分:0)

您需要将完整的日历模块添加到您的应用中

var app = angular.module('yourApp', ['angular-fullcalendar']);
相关问题