angularjs - Angular 1.7.8 - 错误:$injector:unpr 未知提供者
问题描述
我坚持这个问题大约一个小时,我想做的是使用 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')
}
}])
解决方案
您需要将完整的日历模块添加到您的应用中
var app = angular.module('yourApp', ['angular-fullcalendar']);
推荐阅读
- ruby-on-rails-4 - rails_admin 获取当前实体并显示自定义枚举
- javascript - jquery - 使用 .done()、.then() 和 .when() 以给定顺序发出 ajax 请求
- docker - 如何将文件写入 docker 容器的临时目录?
- smalltalk - 在 Smalltalk 中访问消息文档
- python - python找到带有弧度的x,y坐标,给定角度
- javascript - 如何遍历 API 响应并将正确的数据插入到相同的 div 中?
- c# - 未启用 ASP.NET Core 2 CORS
- ansible - 在剧本级别动态包含 var 文件
- python-3.x - 在 Python 3.6 中对具有隐式类型的序列进行迭代
- javascript - 当我使用 $("#table").DataTable().row.add() 添加数据时,JQuery 数据表的宽度会增加